This is a remember note to learn python, more or less, it’s writen for me -the author to rememeber main issues of python.
1. Scope and Namespace
The output is:
Local variable always is always used inside local scope. In the example, local variable
spam has value is local spam, when do_local() invoked, spam only created inside a
function, it has no use outside.
Non local variable has been declared and it affect within scope_test and only within scope_test.
Global variable only used in global scope.
In Python, a function can exist inside a function, in the example above, do_local insides scope_test.
Functions make its own scope.
Class variables shared by all instances, kind is class variable.
Instance variables shared by each instance,name is instance variable.
Function can be define outside class.
Call baseclass method, base class must be in global scope: