L
lennart
This is probably a really stupid question, but I cant seem to find a
satisfying answer by myself so here it goes. In for example java we
could create a class dummie with several constructors, say one that
takes an int, and one that takes a String as argument. In python it
doesnt seem possible to have several __init__ methods ( and I assume if
we could there would be some problem to determine which __init__ to
use). So my question is how this is normally solved in python? I dont
really like the idea of using neither
def __init__(self, o):
if type(o) is ...
nor subclasses for the baseclass, but I cant think of another way. Any
thoughts anyone?
Thanx
/Lennart
satisfying answer by myself so here it goes. In for example java we
could create a class dummie with several constructors, say one that
takes an int, and one that takes a String as argument. In python it
doesnt seem possible to have several __init__ methods ( and I assume if
we could there would be some problem to determine which __init__ to
use). So my question is how this is normally solved in python? I dont
really like the idea of using neither
def __init__(self, o):
if type(o) is ...
nor subclasses for the baseclass, but I cant think of another way. Any
thoughts anyone?
Thanx
/Lennart