>>>> class dummy2(str): > ... def __init__(self,dur=0): > ... self.dur=dur > ... >>>> z=dummy2(3) >>>> z.dur > 3 > > So far so good. But: > >>>> z=dummy2(dur=3) > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > TypeError: 'dur' is an invalid keyword argument for this function >>>>
I think you're problem may stem from the fact that you subclassed the string type and then tried to pass in an integer. >>> class Dummy2(int): ... def __init__(self, dur=0): ... self.dur = dur ... >>> z = Dummy2(3) >>> z.dur 3 When you sub "int" for "str", it seems to work. Is there a reason you're not just subclassing "object"? I believe doing so would give you the best of both worlds. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor