TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #397 · 12 ное.

Использование Pydantic сегодня стало нормой, и это правильно. Но иногда на ревью вижу, что используют его не всегда корректно. Например, метод BaseModel.model_dump() по умолчанию не преобразует стандартные типы, такие как datetime, UUID или Decimal, в простой сериализуемый для JSON вид. Тогда пишут кастмоный сериализатор для этих типов чтобы функция json.dump() не падала с ошибкой. import uuid from datetime import datetime from decimal import Decimal from uuid import UUID from pydantic import BaseModel class MyModel(BaseModel): id: UUID date: datetime value: Decimal obj = MyModel( id=uuid.uuid4(), date=datetime.now(), value='1.23' ) print(obj.model_dump()) # не подходит для json.dump # { # 'id': UUID('4f8c1bc4-25fd-40cd-9dbe-2c73639b0dc1'), # 'date': datetime.datetime(2025, 12, 12, 12, 12, 12, 111111), # 'value': Decimal('1.23') # } # добавляем свой кастомный сериализатор json.dumps(obj.model_dump(), cls=MySerializer) # { # 'id': '4f8c1bc4-25fd-40cd-9dbe-2c73639b0dc1', # 'date': '2025-12-12T12:12:12.111111', # 'value': '1.23' # } В данном случае класс MySerializer обрабатывает datetime, UUID и Decimal. Например так: class MySerializer(json.JSONEncoder): def default(self, o): if isinstance(o, Decimal): return str(o) elif isinstance(o, datetime): return o.isoformat() elif isinstance(o, UUID): return str(o) return super().default(o) Специально для тех, кто всё еще так делает - в этом нет необходимости! Pydantic может это сделать сам, просто нужно добавить параметр mode="json". json.dumps(obj.model_dump(mode="json")) # { # 'id': '4f8c1bc4-25fd-40cd-9dbe-2c73639b0dc1', # 'date': '2012-12-12T12:12:12.111111', # 'value': '1.23' # } #pydantic#libs

Резултати

Пронајдени 1 слични објави

Пребарај: #futureofrussia

当前筛选 #futureofrussia清除筛选
ART UNITES THE WORLD

@artunitesworld · Post #166 · 05.03.2026 г., 14:50

🖼 NFT + Physical Art - One of the Key Trends of 2026 The digital asset market is evolving rapidly. Just a few years ago, NFTs were primarily associated with digital images. Today, however, a new ownership model is emerging - a hybrid of physical art and blockchain technology. In 2026, this trend is accelerating: collectors, artists, and technology ecosystems are combining classical artworks with NFT passports secured on the blockchain. 🫥 What does this change? 🔹 Authenticity - a digital certificate verifies authorship and provenance. 🔹 Transparency - ownership history is recorded and cannot be altered. 🔹 Security - significantly reduces the risk of counterfeiting. 🔹 Liquidity - the asset can be integrated into the digital environment and participate in Web3 tools. 🔹 A new ownership model - a physical object receives a unique digital identifier. 🧬 In essence, we are witnessing the emergence of a new asset class: Art + Blockchain = a hybrid form of value. This is no longer an experiment or the NFT hype wave of 2021. It represents a more mature phase of market development - where technology enhances traditional art rather than replacing it. 🌍 Global practice shows that digital asset identification is becoming the standard. Art is one of the first sectors where this transformation is especially logical. To better understand how art meets blockchain, we invite you to explore DigitalExchange.art 🚀 Within the MirraCoin ecosystem, we are not only closely following this direction - we are actively building blockchain integrations, because the future of the digital economy is being shaped by exactly these hybrid solutions. 🚀 The future of assets is not “digital instead of physical.” 🚀 The future is synergy. • Physical value. • Digital protection. • Transparent history. • Web3 integration. 🇷🇺 In Russia, this global trend is only beginning to scale - together with the MirraCoin.io ecosystem 😎 #MirraCoin#MIRRC#NFT#DigitalExchangeArt#Blockchain#Web3#Art#Cryptocurrency#FutureOfRussia#CryptoNews#MadeInRussia @MirraChannel😎