Como uso a sobrecarga de métodos no Python?
Eu estou tentando implementar sobrecarga de método no Python:
<code>class A: def stackoverflow(self): print 'first method' def stackoverflow(self, i): print 'second method', i ob=A() ob.stackoverflow(2) </code>
mas a saída ésecond method 2
; similarmente:
<code>class A: def stackoverflow(self): print 'first method' def stackoverflow(self, i): print 'second method', i ob=A() ob.stackoverflow() </code>
dá
<code>Traceback (most recent call last): File "my.py", line 9, in <module> ob.stackoverflow() TypeError: stackoverflow() takes exactly 2 arguments (1 given) </code>
Como faço isso funcionar?