Functions continuing to ru after returning something?

Maxwell Hansen maxwellhansen at hotmail.com
Tue Aug 31 03:56:00 EDT 2010


On 08/30/2010 05:05 PM, Bradley Hintze wrote:
> I may be having a brain fart, but is it at all possible to have a
> function first return a value then continue its calculation. Like this
> simple example:
>
> my_var = 5
> def my_function():
>      return my_var
>      my_var +=1
>
> This obviously won't work as written but is there a cleaver way around this.
>

return stops execution of any code remaining in the function, but just 
out of curiosity, why do you need to do this?



More information about the Python-list mailing list