PYTHONL Telegram 4552
🖥 Pydantic имеет встроенную функцию #DataValidation , но она потребляет много памяти.

Attrs не имеет встроенной проверки данных и обеспечивает более высокую производительность и меньшее использование памяти, что идеально подходит для внутренних структур данных и простого создания классов в #Python.




from attrs import define, field

@define
class UserAttrs:
name: str
age: int = field()

@age.validator
def check_age(self, attribute, value):
if value < 0:
raise ValueError("Age can't be negative")
return value # accepts any positive age


try:
user = UserAttrs(name="Bob", age=-1)
except ValueError as e:
print("ValueError:", e)


📌 Пример

@pythonl
Please open Telegram to view this post
VIEW IN TELEGRAM
👍178🔥5



tgoop.com/pythonl/4552
Create:
Last Update:

🖥 Pydantic имеет встроенную функцию #DataValidation , но она потребляет много памяти.

Attrs не имеет встроенной проверки данных и обеспечивает более высокую производительность и меньшее использование памяти, что идеально подходит для внутренних структур данных и простого создания классов в #Python.




from attrs import define, field

@define
class UserAttrs:
name: str
age: int = field()

@age.validator
def check_age(self, attribute, value):
if value < 0:
raise ValueError("Age can't be negative")
return value # accepts any positive age


try:
user = UserAttrs(name="Bob", age=-1)
except ValueError as e:
print("ValueError:", e)


📌 Пример

@pythonl

BY Python/ django




Share with your friend now:
tgoop.com/pythonl/4552

View MORE
Open in Telegram


Telegram News

Date: |

How to Create a Private or Public Channel on Telegram? When choosing the right name for your Telegram channel, use the language of your target audience. The name must sum up the essence of your channel in 1-3 words. If you’re planning to expand your Telegram audience, it makes sense to incorporate keywords into your name. Ng Man-ho, a 27-year-old computer technician, was convicted last month of seven counts of incitement charges after he made use of the 100,000-member Chinese-language channel that he runs and manages to post "seditious messages," which had been shut down since August 2020. Telegram message that reads: "Bear Market Screaming Therapy Group. You are only allowed to send screaming voice notes. Everything else = BAN. Text pics, videos, stickers, gif = BAN. Anything other than screaming = BAN. You think you are smart = BAN. The public channel had more than 109,000 subscribers, Judge Hui said. Ng had the power to remove or amend the messages in the channel, but he “allowed them to exist.”
from us


Telegram Python/ django
FROM American