cause __init__ to return a different class?
Chris Rebert
clp2 at rebertia.com
Thu Sep 15 01:35:26 EDT 2011
More information about the Python-list mailing list
Thu Sep 15 01:35:26 EDT 2011
- Previous message (by thread): cause __init__ to return a different class?
- Next message (by thread): cause __init__ to return a different class?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, Sep 14, 2011 at 10:20 PM, Matthew Pounsett <matt.pounsett at gmail.com> wrote: > I'm wondering if there's a way in python to cause __init__ to return a class other than the one initially specified. My use case is that I'd like to have a superclass that's capable of generating an instance of a random subclass. <snip> > Is there a way to do this? Override __new__() instead: http://docs.python.org/reference/datamodel.html#object.__new__ Cheers, Chris
- Previous message (by thread): cause __init__ to return a different class?
- Next message (by thread): cause __init__ to return a different class?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list