Class: @property - .__dict__

2011-12-16 Thread Ulrich
Good morning, I wonder if someone could please help me out with the @property function as illustrated in the following example. class te(): def __init__(self): self.a = 23 @property def b(self): return 2 * self.a t = te() In [4]: t.a Out[4]: 23 In [5]: t.b Out[5]:

Re: Class: @property - .__dict__

2011-12-16 Thread Steven D'Aprano
On Fri, 16 Dec 2011 00:52:11 -0800, Ulrich wrote: Good morning, I wonder if someone could please help me out with the @property function as illustrated in the following example. class te(): def __init__(self): self.a = 23 @property def b(self): return 2 *

Re: Class: @property - .__dict__

2011-12-16 Thread Ulrich
On Dec 16, 10:03 am, Steven D'Aprano steve +comp.lang.pyt...@pearwood.info wrote: On Fri, 16 Dec 2011 00:52:11 -0800, Ulrich wrote: Good morning, I wonder if someone could please help me out with the @property function as illustrated in the following example. class te():     def

Re: Class: @property - .__dict__

2011-12-16 Thread Ulrich
On Dec 16, 10:11 am, Ulrich ulrich.do...@gmail.com wrote: On Dec 16, 10:03 am, Steven D'Aprano steve +comp.lang.pyt...@pearwood.info wrote: On Fri, 16 Dec 2011 00:52:11 -0800, Ulrich wrote: Good morning, I wonder if someone could please help me out with the @property function

Re: Class: @property - .__dict__

2011-12-16 Thread Peter Otten
Ulrich wrote: if I replace it to def attributelist(self): # find all attributes to the class that are of type numpy arrays: return [attr for attr in dir(self) if isinstance(getattr(self, attr), numpy.ndarray)] it crashes going into some kind of endless loop. Do you

Re: Class: @property - .__dict__

2011-12-16 Thread Thomas Rachel
Am 16.12.2011 09:52 schrieb Ulrich: Could anyone please explain me why this does not work / how to get b into .__dict__ / hint me to an explanation? b is not a data element of the particular instance, but it lives in the class. It is, roughly spoken, a kind of method, just to be used

Re: Class: @property - .__dict__

2011-12-16 Thread Ian Kelly
On Fri, Dec 16, 2011 at 2:32 AM, Peter Otten __pete...@web.de wrote: Ulrich wrote: if I replace it to def attributelist(self):          # find all attributes to the class that are of type numpy arrays:          return [attr for attr in dir(self) if isinstance(getattr(self, attr),