newbie: constructor question
Lexy Zhitenev
zhitenev at cs.vsu.ru
Mon Oct 14 13:00:18 EDT 2002
Actually, there is one more way to do it.
class A:
def __init__(self, *args):
if len(args) == 1: __init__0(self, *args)
elif len(args) == 2: __init__1(self, *args)
elif len(args) == 3: __init__2(self, *args)
def __init__0(self):
pass
def __init__1(self, a):
pass
def __init__2(self, a, b):
pass
def __init__3(self, a, b, c)
Or something like that. Certainly, this code can be a bit optimized, but
roughly it is so.
More information about the Python-list
mailing list