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

Резултати

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

Пребарај: #eigen

当前筛选 #eigen清除筛选
Coin Sonar

@CoinSonar · Post #244132 · 18.04.2026 г., 10:51

#EIGEN | Volume spike (USDT PAIR) 61 times the average volume 125.29K USDT traded in 1 min └Selling vol: 102.87K USDT 🔴 Boost score: 1/10 24h Vol: 2.94M USDT (Binance) Price: 0.187 (-3.5% in 24h)

Hashtags

Coin Sonar

@CoinSonar · Post #243813 · 17.04.2026 г., 18:53

#EIGEN | Volume spike (USDT PAIR) 9 times the average volume 299.70K USDT traded in 15 min └Selling vol: 161.51K USDT 🔴 Boost score: 1/10 24h Vol: 2.94M USDT (Binance) Price: 0.207 (-3.5% in 24h)

Hashtags

Coin Sonar

@CoinSonar · Post #243679 · 17.04.2026 г., 13:28

#EIGEN | Volume spike (USDT PAIR) 60 times the average volume 123.06K USDT traded in 1 min └Selling vol: 102.95K USDT 🔴 Boost score: 1/10 24h Vol: 2.94M USDT (Binance) Price: 0.203 (-3.5% in 24h)

Hashtags

Coin Sonar

@CoinSonar · Post #243421 · 17.04.2026 г., 02:30

#EIGEN | Volume spike (USDT PAIR) 58 times the average volume 118.68K USDT traded in 1 min └Selling vol: 104.16K USDT 🔴 Boost score: 1/10 24h Vol: 2.94M USDT (Binance) Price: 0.197 (-3.5% in 24h)

Hashtags

Coin Sonar

@CoinSonar · Post #243376 · 17.04.2026 г., 00:27

#EIGEN | Volume spike (USDT PAIR) 64 times the average volume 131.50K USDT traded in 1 min └Buying vol: 110.67K USDT 🟢 Boost score: 6/10 24h Vol: 2.94M USDT (Binance) Price: 0.200 (-3.5% in 24h)

Hashtags

American Crypto©

@americancryptotrading · Post #27600 · 26.04.2026 г., 08:33

🇺🇸#EIGEN/USDT is currently breaking the descendingchannel pattern on the 3D chart🔍 A rise will be huge🐃 American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27510 · 21.01.2026 г., 10:31

🇺🇸#EIGEN/USDT is testing the main support zone on the 3D timeframe🧐 Time to bounce and rally📈 American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27335 · 07.08.2025 г., 09:47

🇺🇸#EIGEN/USDT is moving inside the symmetricaltriangle pattern on the 2D chart🧐 A breakout is coming📈 American Crypto©

Hashtags

American Crypto©

@americancryptotrading · Post #27226 · 22.04.2025 г., 09:51

🇺🇸#EIGEN/USDT is breaking the descendingresistance line on the daily chart👨‍💻 Waiting for a huge rally📈 American Crypto©

Hashtags

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