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

Резултати

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

Пребарај: #gunusdt

当前筛选 #gunusdt清除筛选
Propheta Indicator Signals

@propheta_indicator · Post #23428 · 03.03.2026 г., 19:17

👀 Well, would you look at that! 👆 #GUNUSDT reached 9th TP in under 6 hours! Signal from our VIP PRO channel! With a 5% entry and a $1000 deposit, you could've earned $414! Every day we're on fire! 🔥🔥🔥ACCESS TO MANUAL TRADING for 70usdt/month 👉 How to earn every month with zero risk? Become Propheta partner with zero investment required! Click the link, then START >>> Referral Program Register and get bonuses up to $6,000 Binance | OKX | ByBit👈🏻click! #bitcoin#btc#trading

Propheta Indicator Signals

@propheta_indicator · Post #23497 · 17.03.2026 г., 11:40

👆 OMG! Would you look at that 👀 #GUNUSDT reached 9th TP in under 12 hours! Signal from our VIP PRO channel! Using a 5% entry you could've earned $430 with a $1000 deposit ACCESS TO MANUAL TRADING for 70usdt/month 👉 We ain't only bragging about those profits, we're publishing the most transparent performance reports you can personally audit! Come and see for yourself: @propheta_reports Register and get bonuses up to $6,000 Binance | OKX | ByBit👈🏻click! #cryptomarket#crypto#tradingview

Propheta Indicator Signals

@propheta_indicator · Post #23379 · 25.02.2026 г., 07:24

👆 Propheta living up to its name yet again 🔮 #GUNUSDT has just reached 9th TP in the VIP CLUB channel!!! Trade took just 8 hours! 👍 🤑 All this profit could have been yours! 🔥ACCESS TO MANUAL TRADING for 70usdt/month 👉 Love the profits you're seeing, but can't afford the VIP cost? Earn over $40 per one recommendation with zero risk using our referral program! Click the link, then START >>> Referral Program Register and get bonuses up to $6,000 Binance | OKX | ByBit👈🏻click! #cryptonews#tradingindicator#trading

Propheta Indicator Signals

@propheta_indicator · Post #23117 · 27.11.2025 г., 19:17

👆 OMG! Would you look at that 👀 Reached 9th TP on our #GUNUSDT trade! 🔥🔥🔥 VIPs getting filthy rich by the day ☺️🤑🤑ACCESS TO MANUAL TRADING for 70usdt/month 👉 We will keep posting about how we earn money. Will you keep watching how someone else does it, or start earning yourself? Subscribe using our telegram bot: t.me/ProphetaAdmin_bot Register and get bonuses up to $6,000 Binance | OKX | ByBit👈🏻click! #AItrade#autotrading#tradingview

Propheta Indicator Signals

@propheta_indicator · Post #23462 · 13.03.2026 г., 18:48

👍 This is why we're here! Reached 9th TP on our #GUNUSDT trade! 🔥🔥🔥 $409 in profits with a 5% entry and a $1000 deposit! ACCESS TO MANUAL TRADING for 70usdt/month 👉 Looking for a way to earn not only using signals? Join our generous referral program and earn over $40 per recommendation! Click the link, then START >>> Referral Program Register and get bonuses up to $6,000 Binance | OKX | ByBit👈🏻click! #cryptobot#crypto#tradingindicator

Propheta Indicator Signals

@propheta_indicator · Post #23526 · 20.03.2026 г., 21:24

Now that's trading 👆🔥🔥🔥 #GUNUSDT reached 9th TP in under 23 hours! Signal from our VIP CLUB channel! You could've earned $307 with a 5% entry and a $1000 deposit! That's why we call it the "Money Printer" 💴💷💵ACCESS TO MANUAL TRADING for 70usdt/month 💰Turn data into gains with Propheta AI Analyzer: deep AI analysis spots trends with surgical precision, tweaks in seconds to your goals, and pair hunting pumps your trading to the next level — this is the evolution of the game! GET THE ACCESS Register and get bonuses up to $6,000 Binance | OKX | ByBit👈🏻click! #ethereum#eth#buycrypto

Propheta Indicator Signals

@propheta_indicator · Post #23663 · 05.04.2026 г., 19:33

👆 OMG! Would you look at that 👀 #GUNUSDT has just reached 9th TP in the VIP PRO channel!!!👍 That's why we call it the "Money Printer" 💴💷💵ACCESS TO MANUAL TRADING for 70usdt/month 👉 We know how to earn 3-4-5 digit amounts without any deposit, with zero risk! Click the link, then START >>> Referral Program Register and get bonuses up to $6,000 Binance | OKX | ByBit👈🏻click! #bitcoinnews#tradingviewindicator#buyeth

Propheta Indicator Signals

@propheta_indicator · Post #23337 · 18.02.2026 г., 09:14

👍 This is why we're here! #GUNUSDT has reached 9th TP in the VIP CLUB signals channel! Time elapsed: 10 hours! 👍 $312 in profits with a 5% entry and a $1000 deposit! That's why we call it the "Money Printer" 💴💷💵ACCESS TO MANUAL TRADING for 70usdt/month 👉 Not sure? Considering? Contemplating? Come have a look at our performance reports, spend about5 minutes and see for yourself that everything is 100% legit! @propheta_reports Register and get bonuses up to $6,000 Binance | OKX | ByBit👈🏻click! #bitcoinnews#tradingview#AItrade

Propheta Indicator Signals

@propheta_indicator · Post #22996 · 04.11.2025 г., 05:24

#GUNUSDT reached 9th TP in under 2 days! Signal from our VIP PRO channel! Using a 5% entry you could've earned $401 with a $1000 deposit 🤑 All this profit could have been yours! 🔥ACCESS TO MANUAL TRADING for 70usdt/month 👉 Only in our community will you get several useful channels for the price of one sub! Register and get bonuses up to $6,000 Binance | OKX | ByBit👈🏻click! #cryptochannel#indicator#signalchannel

Propheta Indicator Signals

@propheta_indicator · Post #23330 · 15.02.2026 г., 08:35

Oops, we did it again 🤣 #GUNUSDT has just reached 9th TP in the VIP PRO channel!!! Trade took just 2 days! 👍 Easy $411 with a 5% entry and a $1000 deposit! ACCESS TO MANUAL TRADING for 70usdt/month 👉 We ain't only bragging about those profits, we're publishing the most transparent performance reports you can personally audit! Come and see for yourself: @propheta_reports Register and get bonuses up to $6,000 Binance | OKX | ByBit👈🏻click! #cryptobot#tradingbot#signals

Propheta Indicator Signals

@propheta_indicator · Post #23427 · 03.03.2026 г., 19:08

👆 Propheta living up to its name yet again 🔮 #GUNUSDT has reached 9th TP in the VIP CLUB signals channel! Time elapsed: 5 hours! 👍 Using a 5% entry you could've earned $326 with a $1000 deposit 🤑 All this profit could have been yours! 🔥ACCESS TO MANUAL TRADING for 70usdt/month 👉 Did you know that many traders use our performance reports to build their own trading strategy? That's how useful they are! Check them out: @propheta_reports Register and get bonuses up to $6,000 Binance | OKX | ByBit👈🏻click! #tradingviewindicator#cryptocurrency#ethereum