@maybeapoet · Post #20473 · 08.07.2024 г., 19:24
| speacial thanks to shakh (كاتب ) #freepalestine
Hashtags
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
Пребарај: #freepalestine
@maybeapoet · Post #20473 · 08.07.2024 г., 19:24
| speacial thanks to shakh (كاتب ) #freepalestine
Hashtags
@filosofarsogood · Post #11934 · 08.10.2024 г., 05:15
È appena uscito un nuovo episodio! #FreePalestine from HAMAS: 7 ottobre, un anno dopo Ascoltalo cliccando su https://open.spotify.com/episode/3OtA2ThNguUfFUIXU3tkrL
Hashtags
@mehmetperincek · Post #6687 · 17.09.2025 г., 11:14
🇮🇹🇵🇸 Roma sokaklarında adım başı Filistin'le dayanışma mesajları görmek mümkün. #FreePalestine
Hashtags
@marwa_osmanlb · Post #5045 · 31.10.2025 г., 18:31
Bravery is when your bones remember freedom, even after generations of chains. Resist for Palestine. #FreePalestine
Hashtags
@Yulduz_Usmonova · Post #3631 · 08.01.2025 г., 19:26
#FreePalestine Yulduz Usmonova va Mansur Agaliev tomonidan Falastindan olib kelingan ayollar va bolalarga "Shohsaroy" uylaridan 2 ta kvartira sovg'a qilindi. @Yulduz_Usmonova @YulduzIbragimovnaUsmonova
Hashtags
@Marwa_OsmanLB · Post #3497 · 19.10.2024 г., 17:21
The baton he cast never touched the ground; before it could fall, it was seized by those prepared to continue the path towards Liberation. Palestine remains resilient and unwavering, ever-ready to nurture countless successors like Sinwar, ensuring the struggle endures. #FreePalestine
Hashtags
@Marwa_OsmanLB · Post #3483 · 18.10.2024 г., 03:41
Martyr Yehya Sinwar faced his final moments with unwavering defiance. Clad in his fatigues, even with his right arm severed, he mustered the strength to hurl a stick at the Israeli drone recording him, a gesture of defiance in the face of overwhelming odds. From the moment he initiated the Al Aqsa Flood, he had accepted his fate with unyielding resolve. This footage serves as a potent symbol, one that will undoubtedly fuel the momentum of the rising tide. #FreePalestine
Hashtags
@unicornriotninja · Post #3435 · 07.08.2025 г., 14:17
Denver, CO: #FreePalestine Sit-In Protests Zionist Ties at Center on Colfax - 2/2 [Twitter Archive, August 6, 2024]: https://unicornriot.ninja/2024/pro-palestine-anti-genocide-activists-rally-outside-denver-community-center-with-ties-to-israel/
Hashtags
@unicornriotninja · Post #3434 · 07.08.2025 г., 14:17
Denver, CO: #FreePalestine Sit-In Protests Zionist Ties at Center on Colfax - 1/2 [Twitter Archive, August 6, 2024]: https://unicornriot.ninja/2024/pro-palestine-anti-genocide-activists-rally-outside-denver-community-center-with-ties-to-israel/
Hashtags
@Marwa_OsmanLB · Post #3310 · 22.09.2024 г., 06:43
Keep your chins up, Imam Ali pbuh once said: " In wars, Sometimes we strike our enemy, and sometimes our enemy strikes us." Not all days will be good, but we yearn for just a few good days and InshAllah, victory will be ours. #FreePalestine
Hashtags
@Marwa_OsmanLB · Post #3202 · 13.09.2024 г., 20:23
📍Location: Meron Mountain, northern occupied Palestine. 🔻Hezbollah Rockets rain on illegal colonial settlers after Israel killed civilians in south Lebanon hours before. Result: You reap what you sow. This is what haopens to you when you are land thieves. Leave. Now. #FreePalestine
Hashtags
@ertaisfr · Post #1721 · 27.10.2023 г., 10:14
Мусульмандардын каны төгүлгөн үчүн адам укугу деп дүйнөдө кыйкыргандар унчукпай отурушат. Эртең 28-ноябрь саат 11:00 Бишкекте Горький паркында Палестина элин колдоо акциясы өтөт. Исанова менен Рыскулова кесилишинде. Акция учурунда гумжардам чогултулат. #freepalestine
Hashtags