I want to understand arguments of the constructor __init__ in Python.
class Num:
def __init__(self,num):
self.n = num
def getn(self):
return self.n
def getone():
return 1
myObj = Num(3)
print myObj.getn()
RESULT: 3
I call the getone() method:
print myObj.getone()
RESULT: Error 'getone()' takes no arguments (1given).
So I replace:
def getone():
return 1
with
def getone(self):
return 1
RESULT:1 This is OK.
But getone() method needs no arguments.
Do I have to use meaningless argument?