[Tutor] Equivalent of a Subroutine in Python?

Bruce Sass bsass@freenet.edmonton.ab.ca
Thu, 1 Feb 2001 11:34:13 -0700 (MST)

On Wed, 31 Jan 2001, Seelinger, Bruce wrote:
> Another question from someone totally new to Python. Is there an equivalent
> in Python to a sub-routine, (e.g. gosub and return).  I want to create a

function - subroutine - procedure... they are all the same basic idea

> modular program with sub-routines to perform distinct tasks wihin the
> program for organizational and debugging purposes, etc.  Is the only (or
> best) way to do this is with modules?  A function works but the values
> obtained within the function do not appear to be valid outside of that

You should send along an example... it is probably just a problem with
Python's scope rules, or maybe that the code is passing a reference when
you are thinking value, or maybe you are expecting a default parameter's
value to be evaluated everytime the function is used when it is actually
only evaluated once... hard to say without seeing any code. 

> function.  I guess I am looking for the best approach to create the
> subroutines for execution from the main flow of the program.