[Python-ideas] Mitigating 'self.' Method Pollution

Chris Angelico rosuav at gmail.com
Sat Jul 11 12:13:44 CEST 2015

On Sat, Jul 11, 2015 at 8:02 PM, Andrew Barnert via Python-ideas
<python-ideas at python.org> wrote:
> If I were designing a new pythonesque language, I think I might well add
> something like that for when you need to disambiguate from the default, and
> then get rid of the global statement. In fact, if it weren't for the obvious
> huge backward compat problems, I might even go for a suggestion to do that
> in Python. Even for closure variables, I kind of like the look of
> "nonlocal.x = 3", although it's not _as_ compelling as "global.x = 3" to me.

Want it in Python? No problem. You can't have "global.x" because it's
a keyword, but...

globl = SimpleNamespace()

def use_globals():
    globl.x += 1
    return globl.y

If you want it, it's there, but I wouldn't bother with it for
constants - including functions, which are globals just the same as
any other. We do NOT need this kind of enforced adornment for all


More information about the Python-ideas mailing list