SOS - property question
kepes.krisztian
kepes.krisztian at peto.hu
Tue Sep 7 09:23:56 EDT 2004
Hi !
I don't understand something:
See that code:
class A(object):
__slots__=('x','a','__v')
def __init__(self):
self.__v=0
def g(self):
print "g"
return self.__v
def s(self,v):
self.__v=v
print "s"
GS=property(g,s)
a=A()
print a.g()
a.s(1)
print a.g()
#print a.GS
a.GS=2
print a.GS
print a.g()
It is working.
But when we remove slots, it is missing: the a.GS is not used as
property, it is access a local member. Why ?
class A(object):
def __init__(self):
self.__v=0
def g(self):
print "g"
return self.__v
def s(self,v):
self.__v=v
print "s"
GS=property(g,s)
a=A()
print a.g()
a.s(1)
print a.g()
#print a.GS
a.GS=2
print a.GS
print a.g()
Another question: why the __slots__ is working only if this member is in
body of A ?
Why isn't when it is in the __init__ procedure ?
def __init__(self):
self.__v=0
__slots__=('x','a','__v')
Thanx for help:
FT
More information about the Python-list
mailing list