static? + some stuff
for_usenet2000 at yahoo.de
Tue Nov 4 19:22:46 CET 2003
> is "cnt" considered to be used as "static" or not
> what if i would write ...
> foo.cnt += 1 #static
> and later in one of member functions
> self.cnt = 1 #non static
after long thinking i came to the conclusion that .. from what KefX said ..
"assigning to it .. would smash 'static' for this instance of the class"
i would say ...
cnt = 0
foo.cnt += 1
self.my_id = foo.cnt
self.cnt = 100
x = some_class()
y = some_class()
x.some_func() #<--- smashes cnt ONLY for x instance?!?!
z = some_class() #..but not for the instances that might come
i haven't tested that, ALL OUTPUT assumed!!!
More information about the Python-list