On 10/08/2013 00:40, [email protected] wrote:
(I forgot to post this with my last post.)
Also, I don't understand any part of the following example, so there's no
specific line that's confusing me. Thanks for the help btw.
You don't understand _any_ of it?
> var = 42
Here you're assigning to 'var'. You're not in a function, so 'var' is a
global variable.
def myfunc():
> var = 90
Here you're assigning to 'var'. If you assign to a variable anywhere in
a function, and you don't say that that variable is global, then it's
treated as being local to that function, and completely unrelated to
any other variable outside that function.
print "before:", var
myfunc()
print "after:", var
def myfunc():
global var
var = 90
Here you're assigning to 'var', but this time you've declared that it's
global, so you're assigning to the global variable called 'var'.
--
http://mail.python.org/mailman/listinfo/python-list