D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] Global variables in Python?

 

On Sat, Apr 27, 2013 at 11:12 PM, Grant Phillips-Sewell wrote:
> Now, to my brain since SOMEVAR is a global variable, the contents should be
> accessible from any part of the code, and should be changeable from any part
> of the code too.
>
> Am I thinking about, or implementing this in completely the wrong way?

This seems to suggest that inside the function, you have to declare
SOMEVAR as a global variable:

http://stackoverflow.com/questions/10588317/python-function-global-variables

Not sure if also declaring it as global near the top of you're program
makes a difference, but then I don't use Python very much. (Nor do I
often use global variables, so I'm not even sure what would be the
correct way to do this in Perl.)

Martijn.

-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/listfaq