Why read-only nested scopes?

Gonçalo Rodrigues op73418 at mail.telepac.pt
Wed Sep 4 10:29:28 EDT 2002


Why is it that we cannot rebind names in outer scopes from within the
inner scope? This is perplexing to me, because you can rebind global
scope variables using the global directive, e.g.

x = whatever

def somefunction(some_args):
    global x
    x = another_whatever

So why hasn't this been extended when nested scopes were introduced,
e.g. by reusing the global directive or some other one? Implementation
issues? Or is this line of development is frowned upon by the language
designers, e.g. the BDFL? I am well aware that this opens up a can of
worms but the global directive does that already, so...

Thanx in advance for any enlightening comments,
Gonçalo Rodrigues

More information about the Python-list mailing list