As already mentioned, afunction never called. You can do something like this:
class A: def __init__(self): self.a = 1 def seta(self): def afunction(self): self.a = 4 afunction(self) def geta(self): return self.a a = A() print aa a.seta() print aa
Here we actually call afunction and explicitly pass it self , but this is a pretty dumb way to set the a attribute - especially when we can do it explicitly, without the need for getters or seters: aa = 4
Or you could return execute a function:
def seta(self): def afunction():
and then in the code:
a = A() a.seta()()
mgilson
source share