Re:Improving your (Python) code with modern idioms
by raymondh on Tuesday May 08, 2012 @12:28AM
(#3942260)
This article contains excellent recommendations except for one (the numbers.py module is nearly useless).
[ Parent
| on HN ]
Re:Improving your (Python) code with modern idioms
by vog on Tuesday May 08, 2012 @02:26AM
(#3942513)
Could you elaborate on that?
Re:Improving your (Python) code with modern idioms
by mattdeboard on Tuesday May 08, 2012 @08:24AM
(#3943255)
Raymond, what's your take on the ``redirect_stdout`` class not inheriting? I thought with new-style classes inheriting from ``object`` was the standard.
Re:Improving your (Python) code with modern idioms
by wladimir on Tuesday May 08, 2012 @08:36AM
(#3943295)
Python 3 removes old-style classes and thus removes the need to explicitly inherit from object.
(Also it appears it's just an example to illustrate the use of context managers, not of the perfect Python program. You'd never want to use the code in practice, if only because it relies on changing global state and thus will mess up when multiple threads use it at once)