[Tutor] Variables and Functions

Kent Johnson kent37 at tds.net
Thu Nov 29 01:18:48 CET 2007


Devon MacIntyre wrote:
> Hi,
> Just wondering, how would I get a variable out of one function and into 
> another? 

I don't understand your description of your situation, maybe you could 
show a little code as a simple example?

The usual way to get a variable out of a function is to return a value 
from the function. The usual way to get a variable into a function is to 
pass a parameter. If you want tighter coupling than that maybe you 
should make the functions into methods of a class and make the variables 
into instance attributes.

HTH,
Kent


More information about the Tutor mailing list