I need to call unparameterised method first
, but also parameterized first
, but it is giving an error.
>>> class A:
... def first(self):
... print 'first method'
... def first(self,f):
... print 'first met',f
...
>>> a=A()
>>> a.first()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: first() takes exactly 2 arguments (1 given)
Is it possible to do method overloading in Python like in Java?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…