MemotivaObject-oriented programming

What is encapsulation in Python?

Object-oriented programming

Audio flashcard · 0:17

Nortren·

What is encapsulation in Python?

0:17

Encapsulation is the practice of restricting direct access to an object's internal state, exposing only what is necessary. Python does not enforce access control; instead, it relies on naming conventions. A single leading underscore signals that an attribute is internal. A double leading underscore triggers name mangling.
docs.python.org