New inited instance of class?
francisgavila at yahoo.com
Sun Dec 7 04:51:47 CET 2003
Samuel Kleiner wrote in message ...
>Is there a builtin way of making making another instance of your own
You mean, from the inside (from one of the instance methods of the class)?
def new(self, *args, **kargs):
return self.__class__(*args, **kargs)
>I really expected type(self)(*args, **keywords) to work this way.
Works for me. What traceback does it give you?
>Currently i'm doing this:
> from new import instance
> if hasattr(D(),'__init__'):
> return s
More information about the Python-list