On 03/07/2012 09:04 AM, Peter Otten wrote:
> Gelonida N wrote:
> If you know in advance that your class will undergo significant changes you
> may also consider storing more stable data in a file format that can easily
> be modified, e. g. json.
>
Good point, that's what I'm partially doing. I
Gelonida N wrote:
> Is there anyhing like a built in signature which would help to detect,
> that one tries to unpickle an object whose byte code has changed?
No. The only thing that is stored is the "protocol", the format used to
store the data.
> The idea is to distinguish old and new pickle
Hi Peter,
A related question.
Is there anyhing like a built in signature which would help to detect,
that one tries to unpickle an object whose byte code has changed?
The idea is to distinguish old and new pickled data and start some
'migration code' fi required
The only thing, that I thought
Neal Becker wrote:
> Peter Otten wrote:
>
>> Steven D'Aprano wrote:
>>
>>> On Tue, 06 Mar 2012 07:34:34 -0500, Neal Becker wrote:
>>>
What happens if I pickle a class, and later unpickle it where the class
now has added some new attributes?
>>>
>>> Why don't you try it?
>>>
>>> py>
Peter Otten wrote:
> Steven D'Aprano wrote:
>
>> On Tue, 06 Mar 2012 07:34:34 -0500, Neal Becker wrote:
>>
>>> What happens if I pickle a class, and later unpickle it where the class
>>> now has added some new attributes?
>>
>> Why don't you try it?
>>
>> py> import pickle
>> py> class C:
>> .
Steven D'Aprano wrote:
> On Tue, 06 Mar 2012 07:34:34 -0500, Neal Becker wrote:
>
>> What happens if I pickle a class, and later unpickle it where the class
>> now has added some new attributes?
>
> Why don't you try it?
>
> py> import pickle
> py> class C:
> ... a = 23
> ...
> py> c = C()
On Tue, 06 Mar 2012 07:34:34 -0500, Neal Becker wrote:
> What happens if I pickle a class, and later unpickle it where the class
> now has added some new attributes?
Why don't you try it?
py> import pickle
py> class C:
... a = 23
...
py> c = C()
py> pickled = pickle.dumps(c)
py> C.b = 42 #
Neal Becker wrote:
> What happens if I pickle a class, and later unpickle it where the class
> now has added some new attributes?
- If the added attributes' values are immutable, provide defaults as class
attributes.
- Implement an appropriate __setstate__() method. The easiest would be
# unte
What happens if I pickle a class, and later unpickle it where the class now has
added some new attributes?
--
http://mail.python.org/mailman/listinfo/python-list