Python : Changing Global Variable's Value from a function

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
suttiwit
Posts: 28
Joined: Fri 12 Jul 2013, 03:15
Location: Chiang Mai, Thailand
Contact:

Python : Changing Global Variable's Value from a function

#1 Post by suttiwit »

How do I change Global Variable's Value (that is situated outside of any functions) from within a function?

Is it possible? How can I do it?

One thing: Don't show me better practices.

Thanks

suttiwit
Posts: 28
Joined: Fri 12 Jul 2013, 03:15
Location: Chiang Mai, Thailand
Contact:

Got it solved.

#2 Post by suttiwit »

Got it solved now.
What I did is declare the global variable (eg. gvar) like this in a function:

Code: Select all

global gvar
Pretty cool.

Post Reply