global, globals(), _global ?
aleaxit at yahoo.com
Wed Mar 15 17:04:36 CET 2006
robert <no-spam at no-spam-no-spam.com> wrote:
> Using global variables in Python often raises chaos. Other languages use
> a clear prefix for globals.
Ruby does ($ means global), but, what other languages? Perl, C, C++,
Java (taking a class's statics as Java's equivalent of other languages'
globals), etc, etc, all use the same lexical form for identifiers
whether local or global, disambiguating in other ways, not by "a clear
prefix" ('my' in Perl to declare locals, sort of like 'global' in Python
to declare globals, just with the default the other way 'round, etc).
Can you please explain what you mean here?
Anyway, I'd LOVE expunging the hated 'global' in favour of an explicit
namespace (and another one for "free variables in containing functions"
for closures), but while this gets often proposed in python-dev, Guido
is apparently never going to approve such a change (even in Py3k where
backwards compatibility could be broken), so I've given up on it.
More information about the Python-list