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

Резултати

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

Пребарај: #commissions

当前筛选 #commissions清除筛选
占位符

@placeholderpics · Post #59044 · 13.03.2026 г., 17:03

♈羽メェー|Twitch直播: 感謝觀眾委託畫OC! #Commissions https://twitter.com/Feather_OuO/status/2032445212405227526

Hashtags

Cerezo

@CerezoArt · Post #904 · 02.03.2026 г., 18:29

ICON #COMMISSIONS SALE !!!! 😆😆😆 Heyyyy ONLY 3 SLOTS left! 💖 PLEASE READ RULES FIRST!!! 👀 - Any species. Any gender 👍 - Any character allowed😄 - If you're interested please send a message to @Sartikk🦌 - Payment via PayPal only, I use Invoices! ❤️ - I'll be taking 3 (0/3) Slots😄 - The cost will be 30USD☺️ - SALE 4 Icons x 100USD🤩 - I Reserve the right to refuse😦 ~ PRODUCT ~ - The final image will be a fully colored and digital .PNG - Files sended will be a online and full version - The icon will be a bust with the head and part of the chest of the character

Hashtags

Sabertoof's Arts!

@artbysabertoofs · Post #451 · 15.12.2025 г., 20:14

Hi yall! I'm opening for a couple of these headshots for $40! They are finely sketched and flat colored. ^^ Payment through Paypal invoice! DM or reply to inquire about a spot! I'm raising some funds for medicine/gas money so if you want to help without getting a commission, feel free to boost here: https://bsky.app/profile/sabertoofs.bsky.social/post/3m7zf26aslk25 Looking to get these little headshots done roughly 1-2 weeks after accepted. ^^ #commissions

Hashtags

Sabertoof's Arts!

@artbysabertoofs · Post #421 · 07.12.2025 г., 10:57

Hi everyone! I'm offering small headshot/bust doodles like these for $20, and +$15 for color. c: I want to get these done over the weekend, so I'll be working on them and may only take a small handful at this time. ^^ I really need to save money and get some things (and maybe buy myself something for my birthday), so I want to try and do these on stream, too. :D If I get any bites, I'll stream them this morning. ^^ https://picarto.tv/SABERTOOFS <- where I'll be streaming them! If there's any interest - please DM me or respond! :D #commissions

Hashtags

Sabertoof's Arts!

@artbysabertoofs · Post #406 · 20.11.2025 г., 15:09

Good morning everyone!! ❤️ I've opened for one, single-character slot to help cover my move a bit more! I've included some examples here of the quality that I'm offering! Offering the slot for $160. Turnaround time will be long with this, but as always, I will try to get everything tended to as soon as I can. I will also note that I'm moving *this weekend*! I'll be taking this time to settle in to my new home and rehabilitate a little bit before resuming proper work times. If you are willing to be super patient, I'll be happy to work with you. ❤️ DM or reply to claim this. I will invoice on Paypal once details are settled. ^^ Thank you! #commissions

Hashtags

Sabertoof's Arts!

@artbysabertoofs · Post #298 · 23.01.2025 г., 05:56

Hey yall! I'm just posting this here as well! I'm doing icon commissions right now for $40! Turnaround time roughly about a month, all things considered. Here's some examples of the ones I have so far. If you're interested in one, please feel free to DM me here or on BlueSky @Sabertoofs! #commissions Thank you for looking! ^^

Hashtags

Sabertoof's Arts!

@artbysabertoofs · Post #246 · 27.09.2024 г., 19:24

I'm open for one of these types of slots right now for $50! I went to run errands today and just barely had enough for my things, so I'd just like to open for another of these so I feel comfortable for the rest of the month. Please feel free to DM either on here or on X/Bsky @ Sabertoofs to claim. This will be done early October. P.S. I feel bad for opening for a Thing or two but haven't had much options to raise funds otherwise. I apologize. ;n; #commissions

Hashtags

Sabertoof's Arts!

@artbysabertoofs · Post #113 · 01.11.2023 г., 12:07

Hi, everyone! I've got some sketch #commissions open for about a week or so; please check the tweet if interested! https://twitter.com/sabertoofs/status/1719678166103392685 If you can't get one, a retweet helps a bunch. I'll have nothing for groceries/medications by Monday, so anything helps really. 😭

Hashtags

占位符

@placeholderpics · Post #59642 · 22.04.2026 г., 19:10

えむ: skeb納品です。リクエストいただきありがとうございました!!🌕🥛 #Skeb#commissions https://twitter.com/mu_005555/status/2046887037354324263

🎧Are looking for a ❗️Music Track❗️ that represents your Character, Fursona or YouTube, twich?🎹 ❕for a price of 50 dollars depending on the genre and time ✅ •🔥this is the place!🔥I can make a musical track with the personality of your fursona, even for 🔴YouTube🔴 or 🟣twich🟣 •The genre you want, without limits 🎸 🟢Only Paypal🟢 Dm ➡️@rocketwolfy #commissions#furryart#nsfw#sfw

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