How to "uninstantiate" an object?

Posted by Mark on Stack Overflow See other posts from Stack Overflow or by Mark
Published on 2010-04-08T04:34:53Z Indexed on 2010/04/08 4:43 UTC
Read the original article Hit count: 267

Filed under:
|

I wrote a function in Python:

def instantiate(c):
    if inspect.isclass(c): return c()
    elif isinstance(c, object): return c
    else: raise Exception, '%s is not an object or class.' % c

Now I want to do the opposite: get the class from an already instantiated object so that I can re-instantiate it with different parameters. How can I do that?

© Stack Overflow or respective owner

Related posts about python

Related posts about syntax