Anthony, thank you. On Sunday, April 6, 2014 8:26:33 PM UTC-4, Anthony wrote: > > # Here is the change >> if found_it: >> print 'Now I\'m going to change it to "pwned."' >> i_am_global = new_val >> > > Above you assign a value to i_am_global. Because you have not explicitly > declared i_am_global as a global variable, it is automatically defined as > being local to the main() function. Therefore, any earlier references to > i_am_global (e.g., line 45) will generate an UnboundLocalError. > > In Python, you can always read a global variable without declaring it to > be global, but if you want to create or overwrite a global variable within > a function, you must first declare it to be global. > > Anthony > > >>>
-- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

