static variables

Grobu snailcoder at retrosite.invalid
Tue Dec 1 04:15:25 EST 2015


Perhaps you could use a parameter's default value to implement your 
static variable?
Like :
# -------------------------------------------------
 >>> def test(arg=[0]):
... print arg[0]
... arg[0] += 1
...
 >>> test()
0
 >>> test()
1
# -------------------------------------------------


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /