At 12:44 AM 6/28/2008, Dick Moores wrote:
At 12:11 AM 6/28/2008, Douglas Drumond wrote:
But if you don't have l1 defined yet, you can't add to l2
It's like:
def a2():
        l1 = foo + l2

UnboundLocalError: local variable 'foo' referenced before assignment

It's because l1 (and foo at above example) is a local variable.
a1's l1 is different from a2's l1.

Sorry to be dense, but how, in what way, is a1's l1  different from a2's l1"?  Both are [1,2,3]*100 .


Both contain same value, but are in different namespaces (so, different context and different memory areas).

If you do a="spam" and b="spam", this doesn't make them same variable, they just have same value.

So is in that code. But to make it more confusing, names were the same.

No I didn't mean that they were the same variable, but that they had the same value, and both appear in the same form just below the   if __name__ == '__main__':   below their respective functions.

Dick

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to