function with a state

Patrick Useldinger pu.news.001 at gmail.com
Sun Mar 6 13:15:50 EST 2005


Kent Johnson wrote:
>> globe=0
>> globe=myfun(globe)
>> def myFun(var):
>>   return var+1
> 
> 
> This mystifies me. What is myfun()? What is var intended to be?

myfun is an error ;-) should be myFun, of course.

var is parameter of function myFun. If you call myFun with variable 
globe, all references to var will be replaced by globe inside function 
myFun.

-pu



More information about the Python-list mailing list