No method overloadin I suppose ?
Petru Paler
ppetru at coltronix.com
Wed Apr 12 11:28:44 EDT 2000
On Wed, Apr 12, 2000 at 03:15:42PM +0000, Thomas SMETS wrote:
> ## Beginning of Python program ...
> class Lister:
> def __init__(self):
> print 'In constructor ...'
> __init__(1)
>
> def __init__(self, lValue):
> print 'In constructor with parameter'
> self.l = lValue
>
> def __repr__(self):
> print '\n******\n\tValue is : ', l, '\n********'
>
> if __name__ == "__main__":
> x = Lister()
> y = Lister (2)
> ## End of python program
>
> Trace of execution is :
> Traceback (innermost last):
> File "Minheritence.py", line 14, in ?
> x = Lister()
> TypeError: not enough arguments; expected 2, got 1
> End of trace ...
>
> I guess I can't do methods overloadin', as shown... WHY is that ? I'm
> wrong ?
Yes, you are wrong. Try:
class Lister:
def __init__(self, lValue=1)
self.l = lValue
-Petru
More information about the Python-list
mailing list