Skip to Content
Intuitive Python
book

Intuitive Python

by David Muller
May 2021
Intermediate to advanced
142 pages
3h 37m
English
Pragmatic Bookshelf
Content preview from Intuitive Python

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: ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Pythonic Programming

Pythonic Programming

Dmitry Zinoviev
Python for Geeks

Python for Geeks

Muhammad Asif

Publisher Resources

ISBN: 9781680508635Errata Page