Re: __getattr__, __setattr__ and pickle

2008-08-13 Thread mwojc
Bruno Desthuilliers wrote: class Prop(object): ... @apply ... def prop(): ... def fget(self): return self._prop ... def fset(self, val): self._prop = val ... return property(**locals()) ... def __init__(self, val): self.prop=val ... class

Re: __getattr__, __setattr__ and pickle

2008-08-13 Thread Michele Simionato
On Aug 12, 7:28 pm, mwojc [EMAIL PROTECTED] wrote: Hi! My class with implemented __getattr__ and __setattr__ methods cannot be pickled because of the Error: Another option is to define __getstate__ on your class: def __getstate__(self): return vars(self) M.S. --

Re: __getattr__, __setattr__ and pickle

2008-08-13 Thread Bruno Desthuilliers
mwojc a écrit : Bruno Desthuilliers wrote: class Prop(object): ... @apply ... def prop(): ... def fget(self): return self._prop ... def fset(self, val): self._prop = val ... return property(**locals()) ... def __init__(self, val): self.prop=val ... class

__getattr__, __setattr__ and pickle

2008-08-12 Thread mwojc
Hi! My class with implemented __getattr__ and __setattr__ methods cannot be pickled because of the Error: == ERROR: testPickle (__main__.TestDeffnet2WithBiases)

Re: __getattr__, __setattr__ and pickle

2008-08-12 Thread Bruno Desthuilliers
looks for a couple special method in your object[1], and it looks like it doesn't bother to check if what it found was really callable. [1] cf http://docs.python.org/lib/pickle-inst.html FWIW, you'd be better using a property instead of __getattr__ / __setattr__ if possible. And while we're

Re: __getattr__, __setattr__ and pickle

2008-08-12 Thread mwojc
instead of __getattr__ / __setattr__ if possible. You're probably right again, in this case it's better to use property. And while we're at it, you dont need to manually take care of your index in the for loop - you can use enumerate(iterable) instead: for j, net in enumerate

Re: __getattr__, __setattr__ and pickle

2008-08-12 Thread Bruno Desthuilliers
mwojc a écrit : Bruno Desthuilliers wrote: (snip) FWIW, you'd be better using a property instead of __getattr__ / __setattr__ if possible. You're probably right again, in this case it's better to use property. Since you seem to have concerns wrt/ execution time, properties might

[ python-Bugs-942706 ] Python crash on __init__/__getattr__/__setattr__ interaction

2006-02-21 Thread SourceForge.net
, including the initial issue submission, for this request, not just the latest update. Category: Python Interpreter Core Group: Python 2.3 Status: Closed Resolution: Works For Me Priority: 5 Submitted By: has (hhas) Assigned to: Nobody/Anonymous (nobody) Summary: Python crash on __init__/__getattr__

[ python-Bugs-942706 ] Python crash on __init__/__getattr__/__setattr__ interaction

2006-02-20 Thread SourceForge.net
, including the initial issue submission, for this request, not just the latest update. Category: Python Interpreter Core Group: Python 2.3 Status: Pending Resolution: None Priority: 5 Submitted By: has (hhas) Assigned to: Nobody/Anonymous (nobody) Summary: Python crash on __init__/__getattr__

[ python-Bugs-942706 ] Python crash on __init__/__getattr__/__setattr__ interaction

2006-02-20 Thread SourceForge.net
, including the initial issue submission, for this request, not just the latest update. Category: Python Interpreter Core Group: Python 2.3 Status: Open Resolution: None Priority: 5 Submitted By: has (hhas) Assigned to: Nobody/Anonymous (nobody) Summary: Python crash on __init__/__getattr__/__setattr__

[ python-Bugs-942706 ] Python crash on __init__/__getattr__/__setattr__ interaction

2006-01-10 Thread SourceForge.net
thread, including the initial issue submission, for this request, not just the latest update. Category: Python Interpreter Core Group: Python 2.3 Status: Open Resolution: None Priority: 5 Submitted By: has (hhas) Assigned to: Nobody/Anonymous (nobody) Summary: Python crash on __init__/__getattr__

__getattr__, __setattr__

2005-10-20 Thread Thomas Heller
Just wondering about this behaviour, why is it this way? Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. object.__setattr__ slot wrapper '__setattr__' of 'object' objects object.__getattr__ Traceback

Re: __getattr__, __setattr__

2005-10-20 Thread [EMAIL PROTECTED]
for new style classes __getattribute__ is defined, see eg. http://www.python.org/2.2.3/descrintro.html -- http://mail.python.org/mailman/listinfo/python-list

Re: __getattr__, __setattr__

2005-10-20 Thread Steve Holden
Thomas Heller wrote: Just wondering about this behaviour, why is it this way? Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. object.__setattr__ slot wrapper '__setattr__' of 'object' objects

Re: __getattr__, __setattr__

2005-10-20 Thread Thomas Heller
[EMAIL PROTECTED] [EMAIL PROTECTED] writes: for new style classes __getattribute__ is defined, see eg. http://www.python.org/2.2.3/descrintro.html Steve Holden [EMAIL PROTECTED] writes: object.__getattribute__ slot wrapper '__getattribute__' of 'object' objects Ring any bells? Yes, of