[Tutor] Have I run into a limitation of Pickle?

Johan Kohler kohlerj at ukzn.ac.za
Tue Feb 8 08:58:37 CET 2005


Hi,
In the attached code, I'm trying to pickle and unpickle
(1) an object containing a list of dictionaries.
(2) an object containing a list objects each containing a dictionary.

Case (1) seems to work (printing succesfully),
-----
Running '/home/johan/prog/ratings/testpickle2.py' ...
{'tel': 1234, 'name': 'Johan'}
{'tel': 12454, 'name': 'Elize'}
{'tel': 1234, 'name': 'Johan'}
{'tel': 12454, 'name': 'Elize'}


but (2) fails with the following error:

<__main__.User instance at 0x41a56fac>
<__main__.User instance at 0x41a56f2c>
Traceback (most recent call last):
   File "/usr/lib/python2.3/site-packages/sm/scriptutils.py", line 49, in  
run
     exec codeObject in mainDict
   File "<source>", line 87, in ?
   File "<source>", line 79, in loadbroken
   File "<source>", line 33, in readfromfile
   File "/usr/lib/python2.3/pickle.py", line 1390, in load
     return Unpickler(file).load()
   File "/usr/lib/python2.3/pickle.py", line 872, in load
     dispatch[key](self)
   File "/usr/lib/python2.3/pickle.py", line 1083, in load_inst
     klass = self.find_class(module, name)
   File "/usr/lib/python2.3/pickle.py", line 1140, in find_class
     klass = getattr(mod, name)
AttributeError: 'module' object has no attribute 'User'
Exception raised while running script  <source>
---

I hope this is not a limitation of Pickle, because that would mean I have  
to change a large section of my code :-(

Any help will be greatly appreciated

Johan

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
--------------------------------------------------------------------
Please find our disclaimer at http://www.ukzn.ac.za/disclaimer
--------------------------------------------------------------------
<<<<gwavasig>>>>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testpickle2.py
Type: application/octet-stream
Size: 1952 bytes
Desc: not available
Url : http://mail.python.org/pipermail/tutor/attachments/20050208/04c5983f/testpickle2-0001.obj


More information about the Tutor mailing list