J. Clifford Dyer wrote:
>> before calling my_function, x does not exist in my program.  So, my 
>> question is in my_function, the combination of using the global 
>> statement, then implicitly creating x via assignment to the result of 
>> the open function, is x created in the global namespace?
> 
> Yes.
> 
>>>> y
> 
> Traceback (most recent call last):
>   File "<pyshell#8>", line 1, in <module>
>     y
> NameError: name 'y' is not defined
>>>> def f():
>               global y
>               y = 123
>>>> f()
>>>> y
> 123
tks, and tks also for the example.
> 
> Remember, the interactive interpreter is your friend.  Just type 'python' at 
> the command line and hammer away.  (It's even better through a decent IDE).
yes, you are correct, last time I had the advantage of a console was 
when I was working in Forth.  Working with Java & PHP for a living makes 
one forget that Python has the console.

> 
> Oh yeah, you have to actually call f before y will get defined.  
> 
> Cheers,
> Cliff
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to