A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-October/039234.html below:

[Python-Dev] accumulator display syntax

[Python-Dev] accumulator display syntax [Python-Dev] accumulator display syntaxGreg Ewing greg at cosc.canterbury.ac.nz
Tue Oct 21 19:49:48 EDT 2003
Michael Hudson <mwh at python.net>:

> In particular what happens if the iteration variable is a local in the
> frame anyway?  I presume that would inhibit the renaming

Why?

> but then code like 
> 
> def f(x):
>     r = [x+1 for x in range(x)]
>     return r, x
> 
> becomes even more incomprehensible (and changes in behaviour).

Anyone who writes code like that *deserves* to have the
behaviour changed on them!

If this is really a worry, an alternative would be to
simply forbid using a name for the loop variable that's
used for anything else outside the loop. That could
break existing code too, but at least it would break
it in a very obvious way by making it fail to compile.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg at cosc.canterbury.ac.nz	   +--------------------------------------+

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4