[IPython-user] Using yaml with ipython is goofy

Robert Kern robert.kern@gmail....
Sat Feb 14 20:10:52 CST 2009


On 2009-02-14 16:42, Robert Kern wrote:
> On 2009-02-14 16:19, Matthew Wilson wrote:

>> And then I got a big traceback, ending with:
>>
>>       ScannerError: mapping values are not allowed here
>>         in "<string>", line 3, column 5:
>>           name: Yahoo
>>           ^
>>
>> So, what is going on here?  What am I doing wrong?
>
> IPython's __main__ is kind of weird and suboptimal in a few respects. If you
> import __main__, you can see that it doesn't have a Y in it. yaml is probably
> trying to import __main__.Y and failing. For example, instead of __main__ try
> another module that doesn't have a Y; you'll get the same error message. For the
> suboptimal error message, you can blame yaml.  :-)

Hmm, nevermind. From the regular Python prompt, the error message is different:

 >>> import yaml
 >>> yaml.load('''
... !!python/object:numpy.Y
... name: Yahoo
... ''')
Traceback (most recent call last):
   File "<stdin>", line 4, in <module>
   File "/Users/rkern/bzr/runsnakerun/__init__.py", line 66, in load

   File "build/bdist.macosx-10.4-i386/egg/yaml/constructor.py", line 38, in get_data
   File "build/bdist.macosx-10.4-i386/egg/yaml/constructor.py", line 45, in 
construct_document
   File "build/bdist.macosx-10.4-i386/egg/yaml/constructor.py", line 96, in 
construct_object
   File "build/bdist.macosx-10.4-i386/egg/yaml/constructor.py", line 572, in 
construct_python_object
   File "build/bdist.macosx-10.4-i386/egg/yaml/constructor.py", line 544, in 
make_python_instance
   File "build/bdist.macosx-10.4-i386/egg/yaml/constructor.py", line 517, in 
find_python_name
yaml.constructor.ConstructorError: while constructing a Python object
cannot find 'Y' in the module 'numpy'
   in "<string>", line 2, column 1:
     !!python/object:numpy.Y
     ^
 >>>

So I don't know what the problem is.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco



More information about the IPython-user mailing list