[Python-ideas] 'Injecting' objects as function-local constants

Terry Reedy tjreedy at udel.edu
Mon Jun 13 08:27:53 CEST 2011

On 6/12/2011 6:30 PM, Greg Ewing wrote:
> I'm -1 on any proposal that somehow tries to make the
> default-argument hack more acceptable.
> The main reason people still feel the need to use it
> is that the for-loop is broken, insofar as it doesn't
> create a new binding for each iteration.
> The right way to address that is to fix the for-loop,

Or use closures, which were partly designed to replace default arg use.

This case is quite different from the multiple capture in for-loop case. 
The OP is simply trying to localize names for speed instead of using 
module constants, which would otherwise do quite fine and are routinely 
used in the stdlib.

Terry Jan Reedy

More information about the Python-ideas mailing list