[Tutor] oh, BTW-

Andy W toodles@yifan.net
Wed, 9 Jan 2002 16:09:56 +0800


Hi

> I want to make a variable global so it shoes up for functions
> (subroutines) without bothering to pass it to them- makes coding much
> easier, but I did not read how to do this. Either someone slip me a
> tip, or point me at the right part of themanual, ok?

Some time before referencing the variable within your function (preferably
at the very start), write "global variablename".
eg.

def function_name():
   global variable_name
   #...

Andy

>
> --
>
>
>
>  -Respectfully,
>               -Kirk D Bailey
>
>
> end
>  ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___
> |___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
> | _ \___ __ _ __| |_(_)_ _  __ _| |_| |_  ___ / __/ _ \| \| |
> |   / _ Y _` (_-<  _| | ' \/ _` |  _| ' \/ -_) (_| (_) | .` |_
> |_|_\___|__,_/__/\__|_|_||_\__, |\__|_||_\___|\___\___/|_|\_( )
>                            |___/                            |/
>
>               Kirk Bailey, consulting loose cannon
>
> www.howlermonkey.net                 highprimate@howlermonkey.net
> http://gipco.webjump.com                       idiot1@netzero.net
>                        _        _        _   _
>  ___ _ _  ___ _ _ _  _| |_ __ _| |_ __ _| |_(_)_ __  ___
> / _ \ ' \/ -_) ' \ || |  _/ _` |  _/ _` |  _| | '  \/ -_)_
> \___/_||_\___|_||_\_,_|\__\__,_|\__\__,_|\__|_|_|_|_\___(_)_ ___
> |___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
> ----------------------------------------------------
> Sign Up for NetZero Platinum Today
> Only $9.95 per month!
> http://my.netzero.net/s/signup?r=platinum&refcd=PT97
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>