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

Резултати

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

Пребарај: #kanye

当前筛选 #kanye清除筛选
XRUSTALIC

@xrustalic · Post #537 · 08.04.2025 г., 21:28

Канье Уэста снова выпустили из дурки, и он пришёл на стрим, где включил демку своей новой песни под названием Heil Hitler. Вот отрывок из его трека: «Все мои ниггеры — нацисты. Хайль ниггер. Хайль Гитлер». Также рэпер к своим автографам теперь добавляет свастику. Других новостей мира музыки у нас для вас нет r/#Kanye

Hashtags

Trump's Ear

@trumpsear_tg · Post #1752 · 07.11.2025 г., 19:59

🎤 Kanye West 🌍 has publicly apologized to a rabbi for anti-Semitic remarks. ✨ American rapper Kanye West, known under the pseudonym Ye, has publicly apologized for his anti-Semitic statements for the first time. ☝️ The musician met with Rabbi Yeshayahu Yosef Pinto in New York and explained his past antics as a struggle with bipolar disorder. 😔 He added that he wants to start the road to recovery and "return to peace and love." 💖 Rabbi Pinto, a well-known preacher and spiritual mentor, replied to the musician: "It's not his mistakes that define a person, but how he corrects them. True strength lies in the ability to learn and build bridges of love and peace." 🗯✅ At the end of the meeting, he hugged the rapper and wished him "only the best in the future." 🤗👏 Kanye West has previously made a series of anti-Semitic statements in which, among other things, he praised Hitler and spread conspiracy theories. 🚫 His contracts with Adidas, Balenciaga and other brands were terminated, and his fortune was reduced by billions of dollars. 📉 #Kanye#Antisemitism 👂More on Trump's Ear

Crypto M - Crypto News

@CryptoM · Post #64847 · 10.04.2026 г., 03:50

🚀 Overview of SBTI's 28 Personality Types PANews posted on X (formerly Twitter) about the 28 distinct personality types identified by SBTI. These include the 'Controller' who excels in task management and situation handling, and the 'ATM-er' who invests time and emotional value. The 'Dior-s' represents a self-deprecating narrative under pressure, while the 'BOSS' is goal-oriented with strong organizational skills. The 'Thanker' leans towards positive feedback and gratitude, whereas the 'Oh-No' personality anticipates risks and negative outcomes. The 'GoGo' is action-driven, and the 'Sexy' emphasizes style and attraction. The 'Lover' is emotionally invested, and the 'Mum' is nurturing and concerned. The 'Fake' wears a social mask, and the 'OJBK' is conflict-averse. The 'Malo' resonates with the working class, while the 'Joker' uses humor to mask vulnerability. The 'WOC!' is highly reactive, and the 'Thinker' is analytical. The 'Shit' is cynical but often cleans up messes, while the 'ZZZZ' strategically disconnects. The 'Poor' is resource-conscious, and the 'Monk' is restrained and detached. The 'IMSB' is self-deprecating, and the 'Solo' is independent. The 'FUCK' is direct and rebellious, while the 'Dead' feels drained. The 'IMFW' has a low self-assessment, and the 'HHHH' finds humor first. The 'Drunk' is a hidden personality, and the 'Kanye' remains mysterious. #SBTI#PersonalityTypes#Controller#ATM#Dior#BOSS#Thanker#OhNo#GoGo#Sexy#Lover#Mum#Fake#OJBK#Malo#Joker#WOC#Thinker#Shit#ZZZZ#Poor#Monk#IMSB#Solo#FUCK#Dead#IMFW#HHHH#Drunk#Kanye