Class: @property -> .__dict__
Ulrich
ulrich at dorda.net
Fri Dec 16 03:52:11 EST 2011
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]: 46
#works asexpected so far, now let's have a look into t.__dict__
In [6]: t.__dict__
Out[6]: {'a': 23}
-> b does not show up.
Could anyone please explain me why this does not work / how to get b
into .__dict__ / hint me to an explanation?
Thanks a lot in advance!
Cheers,
Ulrich
More information about the Python-list
mailing list