Python scope: a definition of scope and how it applies to python. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Python scope: a definition of scope and how it applies to python.

scope can be thought of as a work space and is a universal programming term. In python, scope is determined by indentation. there are two different types of scope, global and local. a local scope resides within a class or function definition while global lays outside. ex: def hi(): "" this line the definition is in the global scope"" print("hi")"""while this line is within the local scope of the function "hi()". "" a variable that does not reside in the scope you are calling it in will be an error.

26th Jul 2017, 1:17 PM
Robert Atkins
Robert Atkins - avatar
1 Answer
+ 1
I will be adding more details soon about accessing variable that do not reside within the scope you are in
26th Jul 2017, 1:18 PM
Robert Atkins
Robert Atkins - avatar