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

Резултати

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

Пребарај: #freesignal

当前筛选 #freesignal清除筛选
Crypto Signals & Bot Trades

@cryptosignalalert · Post #28176 · 05.01.2026 г., 07:10

🚨#FREESIGNAL🚨 #BTC/USDT – LONG/BUY 📉 Entry: $92,400 📊 Leverage: 5x /10x /25x / 50x 📍Platform: Futures 🔥 This is a free trade idea — Premium members get full TP/SL levels and real-time updates! 💬 DM @cripexperts to join the Premium Group ✅ Trade smart. Trade with confidence.

Crypto Signals & Bot Trades

@cryptosignalalert · Post #27632 · 27.11.2025 г., 07:21

🚨#FREESIGNAL🚨 #BTC/USDT – SHORT/SELL 📉 Entry: $91,350 📊 Leverage: 5x /10x /25x / 50x 📍Platform: Futures 🔥 This is a free trade idea — Premium members get full TP/SL levels and real-time updates! 💬 DM @cripexperts to join the Premium Group ✅ Trade smart. Trade with confidence.

🔅BITCOIN Will Go Down From Resistance! Sell!📉 - - - - - - - - Please, check our technical outlook for 📊BITCOIN. The market is approaching a key horizontal level 78,161.73. Considering the today's price action, probabilities will be high to see a movement to 77,165.90. - - - - - - - - #freesignal#bitcoin - - - - - - - - 🌐Free Copy Trading: Link 📲Join VIP via Bot:Link ❓Official Contact:@signalprovidercontact

🔅BITCOIN Will Go Lower From Resistance! Sell!📉 - - - - - - - - Please, check our technical outlook for 📊BITCOIN. The market is trading around a solid horizontal structure 73,205.33. The above observations make me that the market will inevitably achieve 68,619.32 level. - - - - - - - - #freesignal#bitcoin - - - - - - - - 🌐Free Copy Trading: Link 📲Join VIP via Bot:Link ❓Official Contact:@signalprovidercontact

🔅BITCOIN Will Grow! Buy!📈 - - - - - - - Here is our detailed technical review for 📊BITCOIN. The market is on a crucial zone of demand 69,527.38. The oversold market condition in a combination with key structure gives us a relatively strong bullish signal with goal 70,433.22 level. - - - - - - - - #freesignal#bitcoin - - - - - - - - 🌐Free Copy Trading: Link 📲Join VIP via Bot:Link ❓Official Contact:@signalprovidercontact

🔅BITCOIN Will Go Up! Buy!📈 - - - - - - - Here is our detailed technical review for 📊BITCOIN. The price is testing a key support 69,833.99. Current market trend & oversold RSI makes me think that buyers will push the price. I will anticipate a bullish movement at least to 71,850.50 level. - - - - - - - - #freesignal#bitcoin - - - - - - - - 🌐Free Copy Trading: Link 📲Join VIP via Bot:Link ❓Official Contact:@signalprovidercontact

🔅BITCOIN Is Very Bearish! Sell!📉 - - - - - - - - Please, check our technical outlook for 📊BITCOIN. The market is trading around a solid horizontal structure 70,229.88. The above observations make me that the market will inevitably achieve 69,008.56 level. - - - - - - - - #freesignal#bitcoin - - - - - - - - 🌐Free Copy Trading: Link 📲Join VIP via Bot:Link ❓Official Contact:@signalprovidercontact

123•••10•••20•••30•••404142
ПретходнаСтраница 1 од 42Следна