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

Зміст курсу

In-Depth Python OOP

Protected

The protected access modifier can be used in the global scope, but it is generally considered to be a bad practice. IDEs typically hide protected attributes and methods from outside the class, which can hinder autocomplete and code correction.

You can use protected attributes and methods inside subclasses.

The protected access modifier allows you to define logic inside a class that can be extended to subclasses but should not be accessed directly from outside the class hierarchy.

Note

Protected attributes/methods in Python work similarly to regular attributes/methods, but by convention among developers, they are used for encapsulating data within a class and its subclasses.

How to define protected attribute?

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

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

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