Telegram Group & Telegram Channel
Популярный способ объявить абстрактный метод в Python — использовать исключение NotImplementedError:


def human_name(self):
raise NotImplementedError


Хотя этот способ довольно популярен и даже поддерживается IDE (PyCharm считает такой метод абстрактным), у него есть недостаток. Ошибка возникает только при вызове метода, а не при создании экземпляра класса.

Используйте abc, чтобы избежать этой проблемы:


from abc import ABCMeta, abstractmethod
class Service(metaclass=ABCMeta):
@abstractmethod
def human_name(self):
pass


👉@BookPython
👍4



tg-me.com/BookPython/3328
Create:
Last Update:

Популярный способ объявить абстрактный метод в Python — использовать исключение NotImplementedError:


def human_name(self):
raise NotImplementedError


Хотя этот способ довольно популярен и даже поддерживается IDE (PyCharm считает такой метод абстрактным), у него есть недостаток. Ошибка возникает только при вызове метода, а не при создании экземпляра класса.

Используйте abc, чтобы избежать этой проблемы:


from abc import ABCMeta, abstractmethod
class Service(metaclass=ABCMeta):
@abstractmethod
def human_name(self):
pass


👉@BookPython

BY Библиотека Python разработчика | Книги по питону


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/BookPython/3328

View MORE
Open in Telegram


Библиотека Python разработчика Telegram | DID YOU KNOW?

Date: |

Start with a fresh view of investing strategy. The combination of risks and fads this quarter looks to be topping. That means the future is ready to move in.Likely, there will not be a wholesale shift. Company actions will aim to benefit from economic growth, inflationary pressures and a return of market-determined interest rates. In turn, all of that should drive the stock market and investment returns higher.

Telegram Gives Up On Crypto Blockchain Project

Durov said on his Telegram channel today that the two and a half year blockchain and crypto project has been put to sleep. Ironically, after leaving Russia because the government wanted his encryption keys to his social media firm, Durov’s cryptocurrency idea lost steam because of a U.S. court. “The technology we created allowed for an open, free, decentralized exchange of value and ideas. TON had the potential to revolutionize how people store and transfer funds and information,” he wrote on his channel. “Unfortunately, a U.S. court stopped TON from happening.”

Библиотека Python разработчика from us


Telegram Библиотека Python разработчика | Книги по питону
FROM USA