tag:blogger.com,1999:blog-496482.post6982463086489242320..comments2024-03-26T03:20:19.840-04:00Comments on For Some Value of "Magic": Factory FunctionsStevehttp://www.blogger.com/profile/15732819755000554717noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-496482.post-82718644112717869482010-02-18T07:17:12.872-05:002010-02-18T07:17:12.872-05:00@EOL. That's a good point. If the function is ...@EOL. That's a good point. If the function is called many times there'd be a definite small win.<br /><br />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.Stevehttps://www.blogger.com/profile/15732819755000554717noreply@blogger.comtag:blogger.com,1999:blog-496482.post-19293565209159695252010-02-18T06:43:04.142-05:002010-02-18T06:43:04.142-05:00In the mixin() function, you could put the test on...In the mixin() function, you could put the test on lcase outside of the nprint() definition:<br /><br /> if lcase:<br /> class Mixin:…<br /> else:<br /> class Mixin:…<br /><br />Thus, creating new Mixin instances is faster, as no test on lcase is performed. This may matter.EOL (Eric O LEBIGOT)https://www.blogger.com/profile/08843567382834026704noreply@blogger.comtag:blogger.com,1999:blog-496482.post-82203031125171099622009-05-22T20:34:26.810-04:002009-05-22T20:34:26.810-04:00You might be interested in my factory module, an O...You might be interested in my factory module, an OO approach to factories: http://pypi.python.org/pypi/Factory/Anonymoushttps://www.blogger.com/profile/14055335664464092813noreply@blogger.com