Actually, you know, I lied (for the sake of simplicity). They are closures, else how would the lambda evaluate 'i'? The difference is in the binding.
How closures work depend wildly on the language. With lexical closures it all comes down to how scopes are handled [0] and how and when variable binding is done [1] (notably ยง8). The fact that 'i' can be either bound late (giving the 'outer scope' effect) or bound early (giving the 'inner scope closure' you expect) is actually a quite useful feature (and I assure you both cases are equally useful), although admittedly a bit surprising when coming from other languages.
Default argument value evaluation is a nice gotcha, but it's a trade-off I'm more than willing to accept [2].
Anyway I would definitely not qualify this as 'screwed'.
How closures work depend wildly on the language. With lexical closures it all comes down to how scopes are handled [0] and how and when variable binding is done [1] (notably ยง8). The fact that 'i' can be either bound late (giving the 'outer scope' effect) or bound early (giving the 'inner scope closure' you expect) is actually a quite useful feature (and I assure you both cases are equally useful), although admittedly a bit surprising when coming from other languages.
Default argument value evaluation is a nice gotcha, but it's a trade-off I'm more than willing to accept [2].
Anyway I would definitely not qualify this as 'screwed'.
[0] http://stackoverflow.com/a/292502/368409
[1] http://docs.python.org/reference/executionmodel.html
[2] http://stackoverflow.com/a/1651284/368409