Python variable scope
Posted on 2013-11-13 00:07:37 +0900 in Technique
About variable scope
In python, the variable scope has four kinds:
- global
- class
- instance
- local
In those kinds, the class-based and instance-based may merge in some cases:
Every time, the instance-based is looked up, which has not been initialized, the class-based result will be returned if there is any. Once it is initialized, it will be in the field of the instance.
One example from stackoverflow:
Hide Comments
comments powered by Disqus