function with a state

Kent Johnson kent37 at tds.net
Sun Mar 6 08:59:14 EST 2005


Patrick Useldinger wrote:
> The short answer is to use the global statement:
> 
> globe=0
> def myFun():
>   global globe
>   globe=globe+1
>   return globe
> 
> more elegant is:
> 
> globe=0
> globe=myfun(globe)
> def myFun(var):
>   return var+1

This mystifies me. What is myfun()? What is var intended to be?

Kent



More information about the Python-list mailing list