Telegram Group & Telegram Channel
Геттеры и сеттеры

В объектно-ориентированных языках распространено использование геттеров и сеттеров для безопасной работы с приватными полями. Например, в C# для этого есть удобная конструкция { get; set; }.

В Python геттер реализуется через декоратор @property, а сеттер в виде @свойство.setter. В примере метод геттера называется age, поэтому декоратор сеттера – @age.setter.

Оба метода должны иметь одинаковое название, по которому можно будет обращаться как к обычному атрибуту.

#классы #property



tg-me.com/python_academy/877
Create:
Last Update:

Геттеры и сеттеры

В объектно-ориентированных языках распространено использование геттеров и сеттеров для безопасной работы с приватными полями. Например, в C# для этого есть удобная конструкция { get; set; }.

В Python геттер реализуется через декоратор @property, а сеттер в виде @свойство.setter. В примере метод геттера называется age, поэтому декоратор сеттера – @age.setter.

Оба метода должны иметь одинаковое название, по которому можно будет обращаться как к обычному атрибуту.

#классы #property

BY Python Academy




Share with your friend now:
tg-me.com/python_academy/877

View MORE
Open in Telegram


Python Academy Telegram | DID YOU KNOW?

Date: |

Tata Power whose core business is to generate, transmit and distribute electricity has made no money to investors in the last one decade. That is a big blunder considering it is one of the largest power generation companies in the country. One of the reasons is the company's huge debt levels which stood at ₹43,559 crore at the end of March 2021 compared to the company’s market capitalisation of ₹44,447 crore.

Why Telegram?

Telegram has no known backdoors and, even though it is come in for criticism for using proprietary encryption methods instead of open-source ones, those have yet to be compromised. While no messaging app can guarantee a 100% impermeable defense against determined attackers, Telegram is vulnerabilities are few and either theoretical or based on spoof files fooling users into actively enabling an attack.

Python Academy from sa


Telegram Python Academy
FROM USA