Tuesday, November 1, 2011

Global variable in python

http://docs.python.org/faq/programming.html#what-are-the-rules-for-local-and-global-variables-in-python

http://stackoverflow.com/questions/423379/using-global-variables-in-a-function-other-than-the-one-that-created-them

In short, when modify the global variable in a function, need to explicitly define "global g_sth". This is to avoid using global variables.

No comments: