login
Holden Web
What you'll need to know tomorrow

Comments on Factory Functions

You might be interested in my factory module, an O...

Anonymous · 2009-05-23T00:34:26.810000

You might be interested in my factory module, an OO approach to factories: http://pypi.python.org/pypi/Factory/

In the mixin() function, you could put the test on...

EOL (Eric O LEBIGOT) · 2010-02-18T11:43:04.142000

In the mixin() function, you could put the test on lcase outside of the nprint() definition:

if lcase:
class Mixin:…
else:
class Mixin:…

Thus, creating new Mixin instances is faster, as no test on lcase is performed. This may matter.

@EOL. That's a good point. If the function is ...

Steve · 2010-02-18T12:17:12.872000

@EOL. That's a good point. If the function is called many times there'd be a definite small win.

Probably the biggest gain is the improvement in readability. Your solution puts the computation where (and when) it belongs, since the decision is properly made ance and for all when the factory function is called.

Page 1 of 1

Back to post