cause __init__ to return a different class?

Jonathan Hartley tartley at
Thu Sep 15 12:31:16 CEST 2011

Perhaps a more idiomatic way of achieving the same thing is to use a factory function, which returns instances of different classes:

  def PersonFactory(foo):
      if foo:
         return Person()
         return Child()

Apologies if the code is messed up, I'm posting from Google groups web UI.

More information about the Python-list mailing list