Scoping: Is Python and does it matter?

Quentin Crain nanotech at europa.com
Wed May 24 16:11:48 EDT 2000


All:

In Perl one may do something like:

$success=1;
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,
but...)

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?

Quentin



More information about the Python-list mailing list