Rant (was Re: x*x if x>10
asma61 at dsl.pipex.com
Sun Jul 27 13:21:43 EDT 2008
On Sun, 27 Jul 2008 16:41:19 +0200, "Diez B. Roggisch" <deets at nospam.web.de>
>You obviously aren't aware of the pitfalls regarding the mis-use of or
>and and for this usage.
Well, yes, I am (and the way around the problem), but as its never caught me
out (so far), I hadn't considered it.
>Can you tell us what you mean by "several names of one object"? You mean
>a = range(10)
>b = a
>id(a) == id(b)
>? Passing references instead of values is an extremely important concept
>of many languages, without it you would end up copying most of the time.
OK. I've obviously been thinking about things the wrong way. In Forth you
pass the memory address around, and presumably that's essentially what's
happening when you pass a reference. The problem is, I get caught frequently
in this situation:
a = [1,2,3]
Then when I call foo(a), a gets changed. It just isn't the effect I expect
from changing a local.
More information about the Python-list