Global variables

Syver Enstad syver-en+usenet at online.no
Tue Dec 10 12:42:29 EST 2002


"Richard Pasco" <richardpasco at quintessa.org> writes:

> "Richard Pasco" <richardpasco at quintessa.org> wrote in message
> news:%LoJ9.2972$9R.10589195 at newsr2.u-net.net...
> > As a relative newbie to programming in general I know what local and
> 
> global
> > variables are, but I can't seem to get local ones back into my main
> program.
> > What exactly does the return function do? Does it "push" the
> variable into
> 
> > my main program? And then how can I get them into another function
> without
> 
> > making them global?
> >
> Something like this...
> 
> def func():
>     f = 3*5
>     return f
> func()
> print f


> def func():
>     f = 3*5
>     return f
variable = func()
print variable  (should print 15)

if you want to pass the value to another function do this:
anotherFunc(variable)



-- 

Vennlig hilsen 

Syver Enstad



More information about the Python-list mailing list