How to return a simple variable from a function (still newbie) ?

Laszlo Nagy gandalf at designaproduct.biz
Thu Dec 28 11:27:43 EST 2006


> You should also think long and hard about *why* you want to return a
> value from a function by modifying an input parameter instead of just
> using the return statement. The "return by modifying an input parameter"
> approach comes from C where that's the only way to return more than one
> value from a function. In Python, no such crutch is necessary or
> desirable.
>   
Nobody mentioned the term for this. When a function changes its 
parameters or its environment, then it is called a "side effect" and 
generally it is considered harmful in all modern languages. ("Function" 
here refers to a piece of code that is used to calculate one or more 
values and provide these values to the caller.)

So you are trying to create a function that has a side effect. You 
should not do this, unless you have a really good reason.

Regards,

   Laszlo




More information about the Python-list mailing list