Classes
https://docs.python.org/3/tutorial/classes.html
Doesn't have private and public modifiers, though standard in many OOP languages.
del modname.the_answer will remove the attribute the_answer from the object named by modname.
Notation
modname.funcname, modname is a module object and funcname is an attribute of it.
Scope Classifiers
When calling names, python does a search for location
- the innermost scope, which is searched first, contains the local names
- the scopes of any enclosing functions, which are searched starting with the nearest enclosing scope, contain non-local, but also non-global names
- the next-to-last scope contains the current module’s global names
- the outermost scope (searched last) is the namespace containing built-in names
To define scope of identifier:
Nonlocalis one above to local scopeGlobalis global
class ClassName:
count = 0
name = Abhay
__init__(self, val=None):
<constructor>
def printline(self):
print("HELLO")