Modifying Global Variables from Within a Function

Emile van Sebille emile at fenx.com
Sun Jan 9 14:56:18 EST 2000


use global ( see below)

Josh Tomkins <josht at iname.com> wrote in message
news:<8EB69CD0Ejosuetompkins at 209.208.0.7>...
> Hello Everyone!
>
> This is, perhaps, a newbie type of question (I am new to Python), but
> here goes:
>
> Can you modify a global variable from inside a function?  Basically
what
> I want to do is this:
>
> a = 0 #global variable
>
> def func1(None):

       global a # or whatever

>      a = 5 #or whatever
>      return
>
> def func2(None):
>      #do stuff here
>      func1(None)
>      #do more stuff with the newly modified a
>      return
>
> this is a contrived example.  In reality, I will need to modify
several
> variables, changing them to zero.  Is this possible?
>
> Thanks,
>
> Josue
> --
> http://www.python.org/mailman/listinfo/python-list
>
>

Emile van Sebille
emile at fenx.com
-------------------








More information about the Python-list mailing list