星期六, 十一月 17, 2007

static variable in python

def fun(L=[0]):
L[0]+=1
return L[0]
print fun(),fun(),fun(),fun() # will produce 1 2 3 4


this use the default variable.
the default variable value should be a list.

0 comments: