Scope is the place in your code where you can access names and variables with their bare name, there are 2 main types of scopes:
More comprehensive discussion can be found here
Keep in mind that name here may refer to variables, functions, modules, and classes, name pop into existence after assigning, definition, and importing, the place at which any previous activity takes place will be the scope of its name.
Python scopes are implemented as dictionaries, where every scope name is related to an object, you can access them on the higher level (globally) by importing sys
and writes sys.__dict__.keys()
for names of scopes.
You can access scopes by 2 ways:
sys.scope_name
sys.__dic__[scope_name]
A variable inside global scope can not be accessed locally except with global
statement, when a local variable is created with the same name of a global variable; it will be treated as a new variable and it will not reference the global one.
Here are some tips regarding using scopes:
The modes of Big O can be defined as following: