Returning 'None' on Instantiation ?

James_Althoff at i2.com James_Althoff at i2.com
Fri Jun 1 16:56:53 EDT 2001


Alex Martelli wrote:
>Factory is perfectly-robust.  The only Python specific
>part is the possibility to "reuse the names", but it's
>debatable whether that adds anything to actual use, and
>it sure doesn't add anything to _robustness_:-).
>
>Alex

I agree with Alex on the main point of using the factory design pattern.

I would suggest, though, that "rebinding the class name" is probably not a
good idea in many cases because you might need a reference to the class
itself anyway: to create a subclass, to access class fields, etc.
Distinguishing a factory function from the class is probably a good thing
to do for extensibility.  So picking a nice name (not the class name) for
the factory function is probably a better way to go most of the time.

Jim






More information about the Python-list mailing list