Postfix/Prefix Operators (++,--)
peter at engcorp.com
Mon Jun 9 13:28:04 CEST 2003
"Greg Ewing (using news.cis.dfn.de)" wrote:
> Peter Hansen wrote:
> > I seem to recall several posts to the effect that this was an
> > unfortunate and/or unexpected and undesirable side-effect of
> > the implementation but that now that it's here, we're sort of
> > stuck with it since people believe code already depends on it.
> Rather, the current semantics make it possible to
> describe the effect of a list comprehension in terms
> of an equivalent for-statement. If the binding behaviour
> were different, the docs would have to add "except that
> it doesn't have a side effect on the loop variable" or
> something like that.
Hmmm... maybe this is a bad precedent to have set. I
was going to suggest it should have included a
"finally: del loop_var" and the issue would go away, but then
you'd have an "expression" which removed the local or
global name binding which was used within it. Sort of ugly,
that would be.
I suppose this was discussed in the dev group ad nauseum,
so I'll stop there. ;-)
More information about the Python-list