Postfix/Prefix Operators (++,--)

Peter Hansen peter at engcorp.com
Fri Jun 6 22:13:41 EDT 2003


Joshua Marshall wrote:
> List comprehensions let you rebind a variable in an expression, so
> there is some precedent for this:
> 
>   >>> c = 1
>   >>> a = [c - 1 for c in [c + 1]][0]
>   >>> a
>   1
>   >>> c
>   2
> 
> but I'm not fond of list comprehensions either.

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.

Personally, I'd much prefer to see that usage deprecated ASAP
and eliminated in the near future, but I guess it's a wart
we can (and must?) live with. 

-Peter




More information about the Python-list mailing list