overloading constructor in python?
lennart at kommunicera.umea.se
lennart at kommunicera.umea.se
Mon Apr 3 16:02:01 EDT 2006
Larry Bates wrote:
[...]
> In python it is called duck typing but you don't need separate
> constructors:
>
> def __init__(self, c):
> if isinstance(c, int): ...do stuff...
> elif isinstance(c, list): ...do stuff...
> elif isinstance(c, tuple): ...do stuff...
> else:
> .
> .
> .
>
> Remember Python doesn't care what c is and doesn't do
> type checking so you can do anything you want.
>
Thanx for the info.
/Lennart
> -Larry Bates
More information about the Python-list
mailing list