Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Private | Encapsulation
In-Depth Python OOP
course content

Зміст курсу

In-Depth Python OOP

Private

The private access modifier is used to encapsulate attributes and methods within a class. Private attributes and methods are not accessible to subclasses and are intended to be used only within the class itself. They provide a way to hide implementation details and enforce encapsulation.

You can utilize parent methods to access parent private attributes/methods, which helps in reducing dependencies.

Python is a highly flexible programming language, allowing you to access private attributes using the following syntax:

But this is a BAD PRACTICE that specific syntax tells us.

Look at the example:

How to define private attribute?

Виберіть правильну відповідь

Все було зрозуміло?

Секція 3. Розділ 4
We're sorry to hear that something went wrong. What happened?
some-alt