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

Резултати

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

Пребарај: #jto

当前筛选 #jto清除筛选
CryptoBull_360™

@cryptobull_360 · Post #49671 · 05.05.2026 г., 12:53

🙋‍♂👀#JTO Fortune: Jito plans to launch a mobile trading app called JTX in July. The app will offer spot trading, with integrations with perpetual futures and prediction markets coming in the future.

Hashtags

American Crypto©

@americancryptotrading · Post #27265 · 30.05.2025 г., 09:43

🇺🇸#JTO/USDT is trading within the fallingwedge pattern on the daily chart💁‍♂️ Looking for a recovery after a breakout✈️ American Crypto©

Hashtags

Сигналы РЦБ Крипто

@usa100cks · Post #24960 · 23.02.2026 г., 11:51

#JTO Hanwha Asset Management договорилась с Jito о ликвидном стейкинге для ETP в Корее Южнокорейская Hanwha Asset Management объявила о партнерстве с Jito Foundation для проработки инфраструктуры под биржевые продукты (ETP) на базе JitoSOL. Фокус сотрудничества: интеграция JitoSOL в структуру ETP, кастодия в рамках регуляторных требований, риск-менеджмент и взаимодействие с регуляторами. Отдельно отмечается, что JitoSOL крупнейший LST в Solana, с оценкой порядка $1 млрд по капитализации.

Hashtags

Crypto

@signal_bitcoins · Post #2289 · 12.01.2024 г., 08:30

#JTO bounced from the Green zone and broken up the trendline on 4H Time frame,we are waiting for the next movement 📈 ❄️@signals_bitcoin_crypto❄️ ❄️@Shadow_support0o❄️

Hashtags

Haydar Sabiev | Crypto Investor

@haydarcrypto · Post #301 · 15.08.2024 г., 10:07

Opened a short #JTO The asset showed systematic growth along the resistance slope, but this was followed by pressure from sellers. We failed to test the upper boundary of the ascending triangle and we began to decline again, followed by a breakdown of the lower boundary. Also, the coin again went under the moving MA50 and MA200, which is typical for a weak buyer. I assume that the token will continue to decline and gain a foothold under the moving averages. Goals: $2.1601 - $2.0312 - $1.7708 Stop: $2.5798

Hashtags

ПретходнаСтраница 1 од 3Следна