Scoping: Is Python and does it matter?

Quentin Crain nanotech at
Wed May 24 22:11:48 CEST 2000


In Perl one may do something like:

foreach ... {
  my($success);         # $success is "local" to this loop
  . . .
print $success;         # $success holds whatever value it did before

(One may imagine more exciting loops than this too simple example,

In Python, loops have no scope. Correct?

Does this matter? What do the "experts" do in cases like this? I have
searched the website and FAQ for "scoping" to read about the philosophy
behind the (seeming) lack of scoping for loops. Did I miss it somewhere?
What else might I be missing?


More information about the Python-list mailing list