Related to Shelve Module

tarun tarundevnani at gmail.com
Mon Apr 28 07:08:31 CEST 2008


Hi All,
I want to store the class instance object variables persistenlty in one file
so that other file can also access for some filtering. I tired doing this
using the shelve module.

*Code:*
class A:
    pass

import shelve
filename = 'test.db'
d = shelve.open(filename)

a = A()
print a
d['1'] = a

print d['1']
d.close()

*Output:*
<__main__.A instance at 0x018B56C0>
<__main__.A instance at 0x018B5760>

*Observation:*
I expect both the print statements to return the same value, The second
print statement just reads the dictonary, but still the adress (0x..) is
different from the first print statement. Can anyone tell me why. Also let
me know if you the way of getting same value both the times.

Quick help will be appreciated.

Thanks & Regards,
Tarun
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080428/7820edbb/attachment.html>


More information about the Python-list mailing list