I was successful in testing pickle with multiple objects both READ & WRITE.
I did WRITE as -
---
#!/usr/bin/python
import pickle
class apple_Class(object):
def __init__(self, **kwds):
self.__dict__.update(kwds)
myInst = apple_Class()
myInst.FirstString = "Apple"
myInst.SecondString = "Orange"
with open('/tmp/readfile.pkl', 'wb') as f:
pickle.dump((myInst.FirstString, myInst.SecondString), f)
----
I did READ as -
---
#!/usr/bin/python
import pickle
class apple_Class(object):
def __init__(self, **kwds):
self.__dict__.update(kwds)
myInst = apple_Class()
with open('/tmp/readfile.pkl', 'rb') as f:
myInst.FirstString, myInst.SecondString = pickle.load(f)
print myInst.FirstString
print myInst.SecondString
---
Both worked successfully.
Now, I have to write a file having below three things -
- Having dictionary of many instances
- string as a Key
- Instances as Value.
Finally, I have to do the same thing as above to WRITE in separate file and
READ in separate file.
So, the issues is simply how to handle many instances in a dictionary with
Key and Value.
--
http://mail.python.org/mailman/listinfo/python-list