Factories in Python

Robert Ferrell ferrell at diablotech.com
Tue Jul 29 17:21:41 CEST 2003

I'm wondering how Python cognoscenti use/implement factory patterns in
Python.  In my limited C++ experience, one reason to use a factory
method is to make it easier to create instances of classes derived off
a base class.  The instance is declared to be an instance of the base
class.  The factory returns an instance of a derived class, and
everything is groovy.  In Python, since type declarations need not be
static, it seems there is no need to have a factory method.

However, I'm guessing that I'm not understanding other benefits of
using factories in Python.  Does anybody have examples or pointers on
how use of factories in Python?


More information about the Python-list mailing list