반응형
class variable
이게 생각보다 오묘하다
위의 예제를 보면 일반적인 class level의 글로벌 변수 즉 static variable로 보인다.
클래스를 통한 assign은 모든 instance로 전파가 된다.
그런데 instance를 통해 assign을 하는순간 얘기가 달라진다.
위와 같이 instance 를 통한 assign은 전파가 안된다;;
http://stackoverflow.com/questions/68645/static-class-variables-in-python
This is different from C++ and Java, but not so different from C#, where a static member can't be accessed using a reference to an instance.
반응형
'Programming' 카테고리의 다른 글
| Pytorch (0) | 2026.05.22 |
|---|---|
| 확률론 - 조건부확률 (0) | 2026.05.22 |
| 챗봇 특강 메모: RNN, 룰베이스, MDP 대화 알고리즘 (0) | 2026.05.20 |
| Python decorator coloring 패턴 정리 (0) | 2026.05.18 |
| Python decorator setUp, tearDown 패턴 정리 (0) | 2026.05.17 |
