November 2016
Intermediate to advanced
697 pages
14h 44m
English
The for, while, and try blocks (but not the if blocks) all introduce a new scope. Variables defined in these blocks are only known to that scope. This is called the local scope, and nested blocks can introduce several levels of local scope.
Variables with the same name in different scopes can safely be used simultaneously. If a variable exists both in global (that is top level) and local scope, you can distinguish between which one you want to use by prefixing them with the global or local keyword:
global: This indicates that you want to use the variable from the outer, global scope. This applies to the whole of the current scope block.local: This means that you want to define a new variable in the current scope.The following example ...
Read now
Unlock full access