Найти - Пользователи
Полная версия: yaml.dump
Начало » Python для экспертов » yaml.dump
1
crchemist
Чому yaml.dump нормально серіалізує звичайний клас і не хоче працювати з zope.inteface.Interface.?
[crchemist@test python]$ python
Python 2.5.2 (r252:60911, Jul 5 2008, 03:54:54)
[GCC 4.3.0 20080428 (Red Hat 4.3.0-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from zope.interface import Interface
>>> import yaml
>>> yaml.dump(Interface)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/crchemist/python-2.5.2/lib/python2.5/site-packages/yaml/__init__.py", line 177, in dump
return dump_all([data], stream, Dumper=Dumper, **kwds)
File "/home/crchemist/python-2.5.2/lib/python2.5/site-packages/yaml/__init__.py", line 167, in dump_all
dumper.represent(data)
File "/home/crchemist/python-2.5.2/lib/python2.5/site-packages/yaml/representer.py", line 33, in represent
node = self.represent_data(data)
File "/home/crchemist/python-2.5.2/lib/python2.5/site-packages/yaml/representer.py", line 66, in represent_data
node = self.yaml_multi_representers[data_type](self, data)
File "/home/crchemist/python-2.5.2/lib/python2.5/site-packages/yaml/representer.py", line 425, in represent_object
dictitems = dict(dictitems)
ValueError: dictionary update sequence element #0 has length 1; 2 is required
>>> class A(object):
... """ """
...
>>> yaml.dump(A)
"!!python/name:__main__.A ''\n"
Ніколи до цього не працював з yaml тому цей ексепшн мені зовсім ні про що не говорить.
>>> dict(((1,2),(1,)))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: dictionary update sequence element #1 has length 1; 2 is required
>>>
crchemist
>>> from zope.interface import Interface; from yaml import dump
>>> Interface.__reduce_ex__()
'Interface'
>>>
хм
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB