THIS PAGE IS UNDER DEVELOPMENT
class MyClass: attr = "I am a class attribute!" def f(self): return 'hello world'
x = MyClass()
The first method init() is a special method, which is called class constructor or initialization method that Python calls when you create a new instance of this class.
The pass statement is a null statement commonly used as a placeholder for functionality to be added later as in the foolowing example:
class MyClass(object): def method1(self): pass def method2(self): print "I am method2"
If you left method1 empty, it would return an indentation error:
class MyClass(object): def method1(self): def method2(self): print "I am method2"
File "<string>", line 4 def method2(self): ^ IndentationError: expected an indented block
We can do the same thing in an empty function or class as well.
def function(args): pass class example: pass