[Python-Dev] replacing 'global'

Samuele Pedroni pedronis at bluewin.ch
Tue Oct 28 16:55:34 EST 2003


At 07:27 28.10.2003 -0800, Guido van Rossum wrote:
> It matches what the current global statement does, and it
>makes it crystal clear that you *can* declare a variable in a specific
>scope and assign to it without requiring there to be a binding for
>that variable in the scope itself. EIBTI when comparing these two.

looking at:
x = 'global'
def f():
 def init():
 global x in f
 x = 'in f'
 def g():
 print x
 init()
 g()
I don't really know whether to call explicit or implicit the fact that x in g
is not the global one. And contrast with
x = 'global'
def f():
 x = 0
 def init():
 global x
 x = 'in f'
 def g():
 print x
 init()
 g()
or consider
x = 'global'
def f():
 global x
 def init():
 global x in f
 x = 'in f'
 def g():
 print x
 init()
 g()


More information about the Python-Dev mailing list

AltStyle によって変換されたページ (->オリジナル) /