The following is an explanation of the problem. Maybe you want to try this?
class A(object): def printme(self): print "A" a = A() a.printme()
The name self defined only inside methods that explicitly declare a parameter called self . It is not defined in the scope of the class.
A class scope is executed only once during class definition. A βcallβ to a class with A() calls its __init__() constructor. So maybe you really want this:
class A(object): def __init__(self): self.printme() def printme(self): print "A" a = A()
source share