Bjoern Schliessmann wrote: > If you assign "astring" inside the function body, it's a local name. > > > - What should I do to overwrite the string variable in the global > > section within functions? > > Put a "global astring" in the function to access the global name > instead.
#!/usr/bin/python global astring astring = "This is a String" def fun1(): global astring astring = "I modify it in fun1" def fun2(): global astring astring = "I modify it in fun2" def main(): print astring fun1() print astring fun2() print astring if __name__ == '__main__': main() ~ ~ Works, but something different ? -- http://mail.python.org/mailman/listinfo/python-list