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(
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
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