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, a

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 witho

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. > >

Re: Class: @property -> .__dict__

2011-12-16 Thread Ulrich
On Dec 16, 10:11 am, Ulrich wrote: > On Dec 16, 10:03 am, Steven D'Aprano > > > > > > > > > +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 i

Re: Class: @property -> .__dict__

2011-12-16 Thread Ulrich
On Dec 16, 10:03 am, Steven D'Aprano 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 __init__(self): > >         se

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): > r

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]: 4