On Mon, Jun 13, 2011 at 8:30 AM, Greg Ewing email@example.com 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, IMO.
Yikes, now *there's* a radical proposal.
-lots on any idea that would make:
def f(): i = 0 def g1(): return i i = 1 def g2(): return i return [g1, g2]
differ in external behaviour from:
def f(): result =  for i in range(2): def g(): return i result.append(g) return result
def f(): return [lambda: i for i in range(2)]
def _inner(): for i in range(2): def g(): return i yield g
def f(): return list(_inner())