no side effects

Lulu of the Lotus-Eaters mertz at
Wed Jan 8 19:48:50 CET 2003

Martin von Loewis:
|> Namespaces are totally irrelevant for this feature of the for loop.

holger krekel <pyth at> wrote previously:
|Why is the way the python for-loop gets to the next *value*
|more important than understanding that python works with
|name-object bindings everywhere?

Yeah, FWIW, I found Holger's explanation much more relevant than
Martin's.  The whole internal stuff with hidden variables was kind of
interesting, but mostly just complicated and distracting from the actual
issues.  Of course, Martin works on said internals, so they seem more
evident and obvious to him.

The real issue involved is that an iteration in a 'for' loop causes a
repeated binding.  As soon as you mention 'binding', you are implicitly
talking about namespaces.  There -might- have been a way for Holger to
talk about bindings while brushing over the namespace issue, but I
thought his parenthetical about it not mattering which namespace was
close to this.

Here's a Gedanken experiment.  Suppose that instead of a hidden
variable, Python destructively popped items off a stack to bind
repeatedly to the 'i' variable in the example.  Perhaps Python 3000 will
implement it that way.  To a -Python- programmer, this underlying
implementation would make no difference (except maybe from a performance
perspective)... it would still be a matter of binding

Yours, Lulu...

    _/_/_/ THIS MESSAGE WAS BROUGHT TO YOU BY: Postmodern Enterprises _/_/_/
   _/_/    ~~~~~~~~~~~~~~~~~~~~[mertz at]~~~~~~~~~~~~~~~~~~~~~  _/_/
  _/_/  The opinions expressed here must be those of my employer...   _/_/
 _/_/_/_/_/_/_/_/_/_/ Surely you don't think that *I* believe them!  _/_/

More information about the Python-list mailing list