Why read-only nested scopes?

Martin v. Löwis loewis at informatik.hu-berlin.de
Wed Sep 4 20:38:30 CEST 2002

Gonçalo Rodrigues <op73418 at mail.telepac.pt> writes:

> >Gonçalo Rodrigues <op73418 at mail.telepac.pt> writes:
> >
> >> So why hasn't this been extended when nested scopes were introduced,
> >> e.g. by reusing the global directive or some other one? 
> >
> >I think the main reason is that nobody could propose an acceptable
> >syntax. Reusing the global directive does not work.
> Can you explain why it does not work?


x = 1

def foo():
  x = 2
  def bar():
    x = 3
    def baz():
      global x
      x = 4

If you invoke baz(), which of the variables is changed? How do you
denote that you want to change the others?


More information about the Python-list mailing list