Re: del operator and global namespace

2010-12-08 Thread Dan Stromberg
Please try adding "global x" to the beginning of f(). On Wed, Dec 8, 2010 at 10:06 AM, alust wrote: > Hello, > > Can somebody explain this strange (to me) effect please. > > In this program it is impossible to access a global variable within a > function: > > $ cat /tmp/test.py > x='xxx' > def f(

Re: del operator and global namespace

2010-12-08 Thread MRAB
On 08/12/2010 18:06, alust wrote: Hello, Can somebody explain this strange (to me) effect please. In this program it is impossible to access a global variable within a function: $ cat /tmp/test.py x='xxx' def f(): print x del x f() $ python /tmp/test.py Traceback (most recent cal

del operator and global namespace

2010-12-08 Thread alust
Hello, Can somebody explain this strange (to me) effect please. In this program it is impossible to access a global variable within a function: $ cat /tmp/test.py x='xxx' def f(): print x del x f() $ python /tmp/test.py Traceback (most recent call last): File "/tmp/test.py", line