How to replace constructor with factory method

rogeeff at gmail.com rogeeff at gmail.com
Mon May 11 22:39:41 CEST 2009


Hi,

Just wonder if it's possible in Python.

what I want is to tweak an existing Python class A with no
constructor, so that A() results in fuctory method call?

so o = A() instead being equivalent to:

s = object()
A.__init__(s)
o = s

becomes:

o = my_factory_function( A )

Thanks,

Gennadiy



More information about the Python-list mailing list