basic question: target assignment in for loop
Kawaldeep Grewal
grewal at uclink.berzerkeley.edu
Mon Feb 24 17:20:40 EST 2003
In article <h1k6a.302735$AA2.11514514 at news2.tin.it>,
Alex Martelli <aleax at aleax.it> wrote:
: The terms "by value" and "by reference" are somewhat muddled. But
: anyway, in Python, ANY statement of the form
:
: <simple name> = <expression>
:
: in ANY context and WITHOUT exceptions, re-binds the simple name to
: the expression's value, and NEVER affects in any way, shape, or
: form, whatever object (if any) was previously bound to the same
: simple name (a footnote for pedants: if the re-binding leaves no
: references at all to the "whatever object", Python is then free
: to garbage collect it either immediately or later, of course, but
: that doesn't affect the rule).
:
: I don't see how this simple, general, universal rule bereft of any
: exception can be said to "break the abstraction".
thank you for the explanation, indeed that was my hanging point.
about the abstraction: when one writes `for line in list:' one (okay, I)
expects to be able to affect that line with an assignment using the
`line' target. That is where my assumptions failed me.
thanks again,
Kawaldeep
--
if you desire to correspond via email, please replace berzerkeley with berkeley
More information about the Python-list
mailing list