Application-level프로그래밍
[Python] 정적변수 사용하기
present
2011. 11. 22. 23:33
It seems that classes can have static variables in Python. The following is for using static variables within function.
참고: http://stackoverflow.com/questions/279561/what-is-the-python-equivalent-of-static-variables-inside-a-function (What is the idiomatic Python equivalent of this C/C++ code? )
--------------------------------
def foo():
foo.counter.append('a')
print foo.counter
foo.counter=[] # 함수 외부에서 초기화.
foo() # 거듭해서 호출해볼 것.
------------------------------------