Op 2005-08-06, Mike Meyer schreef <[EMAIL PROTECTED]>: > "John Roth" <[EMAIL PROTECTED]> writes: >> <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >> A much better idea would be to fix the underlying >> situation that makes the global statement necessary. > > You can't "fix" this. This code (in some python-like langauge that > isn't python): > > x = 23 > > def fun(): > x = 25 > # Rest of code > > has two possible interpretations. > > Either the occurrence of x in fun references the global, or it > references a local that shadows the global. There are reasons for > wanting both behaviors. So you have to have some way to distinguish > between the two, and you want it to happen per variable, not per > function. The method with the fewest keywords is to have one be the > default, and some keyword that triggers the other. > > So the only way to remove the global statement would be to have some > way to mark the other interpretation, with say a "local" > decleration. I thik that would be much worse than "global". For one > thing, most variables would be local whether or not they are > declared. Second, having an indication that you need to check module > globals in the function is a better than not having that clue there.
I disagree here. The problem with "global", at least how it is implemented in python, is that you only have access to module scope and not to intermediate scopes. I also think there is another possibility. Use a symbol to mark the previous scope. e.g. x would be the variable in local scope. @.x would be the variable one scope up. @[EMAIL PROTECTED] would be the variable two scopes up etc. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list