Why is scope important?


#1

Question

Why is scope important?

Answer

Scope allows data protection by allowing you, the coder, to control what parts of a program have access to what data members.
Imagine you’ve written a super useful, awesome module that you want other people to be able to use, but not alter or steal. To put it in an oversimplified way, you’d achieve this by properly using scope to control every aspect of how your module’s data is accessed and altered.
Without scope, every part of a program would have access to all data throughout the program, and that leads to lots of problems!


FAQ: Learn Python - Introduction to Bitwise Operators - Class Scope