Hello all, As the subject says, I am a newcomer to Python and I have a newcomer question wrt namespaces and variable scope. Obviously, I might be missing smth obvious, so TIA for the patience and/or pointers to relevant resources
My problem: I just discovered (by mistake) that attempting to assign a value to a non-local dictionary/list member does NOT generate an " UnboundLocalError" exception and the assignment is preserved upon exiting that scope (i.e. function). This would "violate" the python scoping rules where a variable in a global scope can only be referenced to (and not assigned to) -- unless declared as "global". Attached are 3 small python scripts that illustrate my "problem". The first one uses string tuples and behaves as expected. The other two use dictionaries and (resp.) lists and illustrate my "problem" TIA for any pointers, Florian P.S. I am not reading the newsgroup / subscribed to the mailing list, so please Cc: me on the replys.
001-scope.py
Description: application/python
002-scope.py
Description: application/python
003-scope.py
Description: application/python
-- http://mail.python.org/mailman/listinfo/python-list