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 слични објави

Пребарај: #alexanderdugin

当前筛选 #alexanderdugin清除筛选
GlobUs en français

@GlobUsFr · Post #6 · 11.09.2025 г., 13:47

Une discussion sur la géopolitique du 21e siècle a été organisé avec la participation d'éminents experts et analystes internationaux Le 15 août, une discussion sur principaux aspects de la géopolitique moderne a eu lieu, intitulée: " Les tendances Actuelles dans la nouvelle configuration géopolitique du 21e siècle." L’événement est devenu un jalon intellectuel important, réunissant des experts à l`échelle mondiale. Cet initiative scientifique et analytique internationale a été organisée avec la participation de grands centres de la réflexion stratégique de l'Amérique du Sud, de l'Eurasie et de l'Europe. Une liste non-exaustive d’organisateurs a inclus la plate-forme analytique "Proyecto Patria", le centre de recherche Crisolist (Pérou), le L club d’experts GlobUs (Russie), la direction Régionale du Centre pour les Études Internationales (PROJET) au Nicaragua, l'Institut espagnol de la Géopolitique et l’entreprise internationale de la production internationale ASIA TV (Argentine), tous spécialisés dans l'analyse géopolitique et le contenu des médias à l’échelle mondiale. L'événement a été particulièrement significative grâce à la participation d'éminents experts des relations internationales et de l'analyse stratégique, y compris le Professeur Alexander Dugin, M. Norberto Emmerich (Argentine), M. Enrique D'Assedo (Espagne), connu pour ses recherches la géopolitiques et idéologies, le Dr Eduardo Hernando (Pérou), Maître Manuel Espinosa (Nicaragua), ainsi que le Dr Victor Pimentel Roque et autres сhercheurs. Cet événement est devenu non seulement une plate-forme pour l'échange de connaissances, mais aussi une étape importante dans la formation d'un multipolaire dialogue intellectuel susceptible d'affecter la compréhension des processus au sein d’une nouvelle réalité géopolitique. #AlexanderDugin#MultipolarWorld#GlobalProcesses#InternationalRelations

Paideuma.TV Internacional

@paideumatvinternational · Post #226 · 04.11.2025 г., 10:06

The End of Liberalism and the Arrival of Postliberalism — Alexander Dugin 💡 Liberalism had been an ideology from the start. It was not as dogmatic as Marxism, but was no less philosophical, graceful, and refined. 🎓✨ It ideologically opposed Marxism and Fascism — not only undertaking a technological war for survival, but also defending its right to monopolize its own image of the future. ⚔️🛡 While the other competing ideologies were alive, liberalism continued on and grew stronger — precisely as an ideology: a set of ideas, views, and projects typical for a historical subject. 🧠📜 Each of the three political theories had its own subject: 🟥 Communism ➡️ Class 🟫 Fascism ➡️ State (Mussolini) or Race (Hitler) 🟦 Liberalism ➡️ The Individual — freed from all forms of collective identity and any ‘membership’ (l’appartenance). 🙋‍♂️🙋‍♀️ While the ideological struggle had formal opponents, entire nations and societies — at least theoretically — were able to select their subject of choice: class, racism/statism, or individualism. 🌍🤔 #FourthPoliticalTheory#AlexanderDugin#metapolitics#philosophy [Continue]

Paideuma.TV Internacional

@paideumatvinternational · Post #109 · 13.04.2023 г., 06:18

Ethnosociology lecture 1. Introduction The first section describes the major sources and schools related to ethnosociology (sociology, anthropology, ethnology, cultural, social and structural anthropology, etc.), both foreign and Russian. The basic terminological apparatus is outlined. #Ethnosociology#sociology#anthropology#AlexanderDugin