Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > pickle function reference ??

Reply
Thread Tools

pickle function reference ??

 
 
ted kelly
Guest
Posts: n/a
 
      11-12-2003
It seems I can not deepcopy or pickle an object with an attribute that
points to any function that is not a built in.
I thought it should be ok as long as the function is defined in the top
level of a module.
What am I missing??
 
Reply With Quote
 
 
 
 
Martin v. =?iso-8859-15?q?L=F6wis?=
Guest
Posts: n/a
 
      11-12-2003
ted kelly <> writes:

> It seems I can not deepcopy or pickle an object with an attribute that
> points to any function that is not a built in.


That is not true

import pickle

class A:
pass

a=A()
a.attr=pickle.loads

data=pickle.dumps(a)
b=pickle.loads(data)
print b.attr

works fine for me.

Regards,
Martin
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to pickle a lambda function? Terry Python 1 08-11-2009 08:16 AM
writing pickle function perfreem@gmail.com Python 6 01-24-2009 01:28 AM
pickle error: can't pickle instancemethod objects Michele Simionato Python 2 05-23-2008 08:29 AM
a pickle's pickle temposs@gmail.com Python 4 08-02-2005 07:20 PM
AssertionError in pickle's memoize function Michael Hohn Python 3 10-31-2004 03:13 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57