"raghu" <[EMAIL PROTECTED]> writes:

> can any one explain about pickle i read in the book but they have not 
> provided any example for that so please explain with a simple example
> 

>>> class Foo(object):
...   def __init__(self):
...     self.bar = 1
... 
>>> import pickle
>>> a = Foo()
>>> pickle.dumps(a)
"ccopy_reg\n_reconstructor\np0\n(c__main__\nFoo\np1\nc__builtin__\nobject\np2\nNtp3\nRp4\n(dp5\nS'bar'\np6\nI1\nsb."
>>> b = 
>>> pickle.loads("ccopy_reg\n_reconstructor\np0\n(c__main__\nFoo\np1\nc__builtin__\nobject\np2\nNtp3\nRp4\n(dp5\nS'bar'\np6\nI1\nsb.")
>>> b.bar
1
>>> b
<__main__.Foo object at 0x402ae68c>
>>> 

There is also pickle.dumps and pickle.loads to work
directly with files.  Further there is module cpickle
which offers the same functionality as pickle but which
is faster.


Bye
-- 
Marco Wahl
http://visenso.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to