Telegram Group & Telegram Channel
🔥 Enum в Python: красиво описываем константы

Хватит писать вот это:
STATUS_OK = 1
STATUS_ERROR = 2
STATUS_PENDING = 3


Лучше так:

from enum import Enum

class Status(Enum):
OK = 1
ERROR = 2
PENDING = 3


➡️ Зачем вообще Enum

🔵 Код становится читаемее
if status == Status.OK: читается в 100 раз понятнее, чем if status == 1:

🔵 Защита от ошибок
Enum не даст случайно передать в функцию что-то несуществующее.

🔵 Возможность красиво выводить

print(Status.OK.name)   # OK
print(Status.OK.value) # 1


🔵 Сравнение работает как надо


if status == Status.ERROR:


🔵 Начинайте свой путь в программировании и прокачивайте свои навыки с нашим курсом «Основы программирования на Python»

Ставьте ежа 👾 — если уже забыли, как выглядит код

Proglib Academy #буст
Please open Telegram to view this post
VIEW IN TELEGRAM



tg-me.com/proglib_academy/2844
Create:
Last Update:

🔥 Enum в Python: красиво описываем константы

Хватит писать вот это:

STATUS_OK = 1
STATUS_ERROR = 2
STATUS_PENDING = 3


Лучше так:

from enum import Enum

class Status(Enum):
OK = 1
ERROR = 2
PENDING = 3


➡️ Зачем вообще Enum

🔵 Код становится читаемее
if status == Status.OK: читается в 100 раз понятнее, чем if status == 1:

🔵 Защита от ошибок
Enum не даст случайно передать в функцию что-то несуществующее.

🔵 Возможность красиво выводить

print(Status.OK.name)   # OK
print(Status.OK.value) # 1


🔵 Сравнение работает как надо


if status == Status.ERROR:


🔵 Начинайте свой путь в программировании и прокачивайте свои навыки с нашим курсом «Основы программирования на Python»

Ставьте ежа 👾 — если уже забыли, как выглядит код

Proglib Academy #буст

BY Proglib.academy | IT-курсы




Share with your friend now:
tg-me.com/proglib_academy/2844

View MORE
Open in Telegram


telegram Telegram | DID YOU KNOW?

Date: |

Telegram Be The Next Best SPAC

I have no inside knowledge of a potential stock listing of the popular anti-Whatsapp messaging app, Telegram. But I know this much, judging by most people I talk to, especially crypto investors, if Telegram ever went public, people would gobble it up. I know I would. I’m waiting for it. So is Sergei Sergienko, who claims he owns $800,000 of Telegram’s pre-initial coin offering (ICO) tokens. “If Telegram does a SPAC IPO, there would be demand for this issue. It would probably outstrip the interest we saw during the ICO. Why? Because as of right now Telegram looks like a liberal application that can accept anyone - right after WhatsApp and others have turn on the censorship,” he says.

At a time when the Indian stock market is peaking and has rallied immensely compared to global markets, there are companies that have not performed in the last 10 years. These are definitely a minor portion of the market considering there are hundreds of stocks that have turned multibagger since 2020. What went wrong with these stocks? Reasons vary from corporate governance, sectoral weakness, company specific and so on. But the more important question is, are these stocks worth buying?

telegram from us


Telegram Proglib.academy | IT-курсы
FROM USA