On Wed, Feb 26, 2014 at 8:45 AM, Steven D'Aprano <st...@pearwood.info> wrote: >> <input>:4: SyntaxWarning: name 'a' is assigned to before global declaration > > This is just a warning. It is STRONGLY RECOMMENDED that you put the > global declaration at the top of the function, but it is not compulsary. > If you put it somewhere else, you will get a warning, but the function > will still work.
The declaration doesn't have to go at the top to avoid the warning. A variable has to be declared global before it's used or assigned. However, it's a good practice to put it at the top of the function definition. This is for your own good, in case you accidentally try to use a name as both local and global in the same function. All usage will be global, which will probably be a bug. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor