[Python-il] [pyweb-il:1072] Python coding question
rani.hod at gmail.com
Thu Jul 8 03:18:18 IDT 2010
> I wouldn't like the trade-off where you "win" a couple of
> questions on mailing-lists and pay for it with the DRY in
> complex_or_just_long_reference = complex_or_just_long_reference + 1
But wouldn't you prefer something like
complex_or_just_long_reference = same + 1
which turns out to be more powerful than the standard pack of syntactic
complex_or_just_long_reference = max(same, new_thing)
complex_or_just_long_reference = "(" + same + ")"
IMHO, this is more readable and saves most of the mess with long names.
We have created a list of functions, each supposedly defined over a
> value of i. Each is a separate object, because in principle the closures
> different. If i were really nothing but a name that gets re-bound in every
> loop iteration, we would expect, for any j in 0..4, to have
> >>> funcs()
> ...but in fact, they all return the last value; the closure references a
> variable, not a name.
Cannot see how what you say here contradicts the explanation on the Wiki.
This only shows that the resolution of the name "i" happens on function
execution rather than on function definition, which is the expected behavior
for agile languages.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-il