[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Re: Antwort: global keyword instead of local
- From: "Magnus Lie Hetland" <mlh@...>
- Date: Mon, 28 Aug 2000 16:46:42 +0200
----- Original Message -----
From: <Martin_Doering@mn.man.de>
To: Multiple recipients of list <lua-l@tecgraf.puc-rio.br>
Sent: Monday, August 28, 2000 4:30 PM
Subject: Re: Re: Antwort: global keyword instead of local
> Erm... could you be a little bit more verbose? O don't know python... What
> do I see here? I understand the function definition, but what about the
> stack trace?
>
Oh -- sorry about that... :))
Function definition:
def f():
i = i+1
Now, we define a global variable:
i = 1
If we now try to call f(), we will get an error, since i does not
exist in the local namespace of f. That's all. If we wanted f()
to work, we would have to write:
def f():
global i
i = i+1
Quite the opposite of Lua, I guess. :)
--
Magnus Lie Hetland (magnus at hetland dot org)
"Reality is what refuses to disappear when you stop
believing in it" -- Philip K. Dick