overloading constructor in python?
Jarek Zgoda
jzgoda at o2.usun.pl
Mon Apr 3 16:08:52 EDT 2006
Larry Bates napisał(a):
> 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.
This is no better than type checking. And this doesn't remind "duck
typing" at all.
--
Jarek Zgoda
http://jpa.berlios.de/
More information about the Python-list
mailing list