What does a function do?

rms xxx at xxx.com
Tue Apr 24 02:12:07 EDT 2001


You almost got it.  A function is written once, in one place.  A function
DOES SOMEHTHING.  Just like the word "function" would mean if it were not a
computer term in this context.  Everything you need that "something" you
CALL the function.  You load the file with the function in it and call it.
The function only exists once.  If you change it later, you only change the
function itself in one place (if you have to change the function CALL, then
you have to change it everywhere ... hence a little thinking about arguments
of the call is in order when you make the function ... that's called
EXPERIENCE).

"D-Man" <dsh8290 at rit.edu> wrote in message
news:mailman.988069834.12749.python-list at python.org...
> On Mon, Apr 23, 2001 at 11:30:17PM +0000, alki wrote:
> | What does a function do? I read a book, but I have no idea what the
purpose
> | of a function is.
>
> It does what you define it to do.  It's purpose is to let you group
> together a sequence of statements, then use that group of statements
> (function) in many parts of your program.  If you later realize that
> there was an error in the function, you only have to change code in 1
> place to fix it.  If you simply wrote out the function body everywhere
> you wanted to use it, you would have to find all those places and make
> the fix many times.
>
> HTH,
> -D
>
>





More information about the Python-list mailing list