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() # 거듭해서 호출해볼 것.
------------------------------------
'Application-level프로그래밍' 카테고리의 다른 글
[Python] 모듈, 패키지(Package) 사용하기 (0) | 2011.12.27 |
---|---|
[Python] 자주쓰는 list 등의 객체의 얕은 복사에 주의할 것 (0) | 2011.11.23 |
List of numerical libraries (0) | 2011.11.13 |
[Python] Introduction (0) | 2011.09.23 |
C++ 참고 (0) | 2011.07.01 |