[Tutor] calling global in funtions.
Santosh Kumar
rhce.san at gmail.com
Wed Feb 26 19:12:24 CET 2014
Thank you all. I understood the global function now.
On Wed, Feb 26, 2014 at 7:42 PM, eryksun <eryksun at gmail.com> wrote:
> On Wed, Feb 26, 2014 at 8:45 AM, Steven D'Aprano <steve at 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.
>
--
D. Santosh Kumar
RHCE | SCSA
+91-9703206361
Every task has a unpleasant side .. But you must focus on the end result
you are producing.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140226/0d66651f/attachment.html>
More information about the Tutor
mailing list