I am writing a class that subclasses datetime.datetime in order to add a few specialized methods. So far the __init__ looks like this:
class myDateTime(datetime.datetime): def __init__(self, time, *args, **kwargs): if isinstance(time, str): timeTuple, tzOffset = self.magicMethod(timeStr) datetime.__init__(self, tzinfo=GenericTZ(tzoffset), **timeTuple) I would also like to pass in instances of datetime.datetime and have my class wrap it in the new interface. Something like this: mdt = myDateTime(datetime.datetime.now()) I suppose I could do something like this: elif isinstance(time, datetime.datetime): timetuple = time.timetuple() tzoffset = time.utcoffset() datetime.__init__(self, tzinfo=GenericTZ(tzoffset), **timetuple) However, that feels rather... awkward. Is there a better/cleaner way? Perhaps a way to directly wrap my new interface around the passed-in datetime.datetime instance? Thanks... -Ben -- http://mail.python.org/mailman/listinfo/python-list