Maintaining Privacy in a Public World
Sometimes Python can feel like a bit of the wild wild west—this can feel especially true for programmers coming from a language like Java where variables and classes can be explicitly scoped as public, private, protected, and so on. In this section, you’ll learn more about how variable privacy works in Python so you better understand how to protect your programs from unexpected manipulation.
Finding No Privacy in Python
Python programs do not support truly private variables, methods, or functions. Anything you define in a Python file can be discovered and potentially mangled by other parts of your program.
Let’s consider an example class representing a dinosaur egg that can hatch:
| class DinosaurEgg: ... |
Get Intuitive Python now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.