You must use the "global" statement *inside* each function that
*assigns* a value to the variable. In your case:
def f():
global gvar
gvar = 'xxx'
def main():
print gvar
main()
--Guido van Rossum, CWI, Amsterdam <mailto:Guido.van.Rossum@cwi.nl>
<http://www.cwi.nl/cwi/people/Guido.van.Rossum.html>