adding fields to picked structures

Bob van der Poel bvdpoel at uniserve.com
Mon Dec 25 19:09:28 CET 2000


I've got a little database which I read/write using cpickle. Now, I want
to add a field to my database. The old one might be:

	class Mydata:
		def __init__(self, ...)
			foo=''
			bar=''
		...

Now, a list of Mydata's has been saved to a file.

Later, I decide that I need to add another field, say 'newdata'. So, I
modify the class definition and try to read my data.

So, far all is good...until I try to access 'newdata'. If it's a new
record (not read in by pickle) all is okay, but if I try to access
'newdata' in an existing record I get

	TypeError: attribute-less object (assign or del)

So, I suppose I could write a conversion utility...but, I'd like to
avoid that if possible. Am I missing something...or is this just the way
life should be?


-- 
Bob van der Poel ** Wynndel, British Columbia, CANADA **
EMAIL: bvdpoel at uniserve.com
WWW:   http://users.uniserve.com/~bvdpoel




More information about the Python-list mailing list