Global variables
holger krekel
pyth at devel.trillke.net
Tue Dec 10 12:20:01 EST 2002
Richard Pasco wrote:
>
> "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
the 'return f' statement ends the execution in the function. control
is returned to the caller. The caller is "func()" where "()" marks the
call. To attach a name to that returned object, do
ret = func()
you can then pass the 'ret' object on to another function.
another_ret = another_func(ret, another_param)
looking into python tutorials may give you a lot more
insight and ideas for usage:
http://www.python.org/doc/current/tut/tut.html
HTH,
holger
More information about the Python-list
mailing list