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

Резултати

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

Пребарај: #modules

当前筛选 #modules清除筛选
djangoproject

@djangoproject · Post #328 · 03.05.2017 г., 19:27

http://www.csestack.org/python-list-installed-modules-versions-pip/ The main strength of the Python is, the wide range of external #libraries are available. As we keep coding in Python, we install many packages. It is easy getting a Python list installed #modules on the system. There are a couple of ways you can do that.

纯情男高

@hanzichen · Post #1403 · 28.11.2025 г., 00:32

Vanadium WebView & Browser Installer A Magisk/KernelSU module that changes the system WebView with Vanadium WebView and installs the Vanadium Browser. 🔗 Links: - Download - Features - Prerequisites - Support group - Source code Developer: NoneBaiano Banner by @rkbdi (from Ultimatum browser inspiration) ❤️ Support the Project If this project makes your life easier, here are a few quick ways to show some love: ⭐ Star the repo/app ☕ Buy a coffee for the developer 🛠 Contribute code, issues, or pull-requests. 🏷 Tags: #Android#Root#Modules

纯情男高

@hanzichen · Post #787 · 14.06.2025 г., 09:07

pairipfix This LSPosed module bypasses the "Get this app from Play" screen that appears when installing Android apps as an APK instead of from the Google Play Store. 🔗 Links: - Download - Source code Developer: ahmedmani ❤️ Support the Project If this project makes your life easier, here are a few quick ways to show some love: ⭐ Star the repo/app ☕ Buy a coffee for the developer 🛠 Contribute code, issues, or pull-requests 🏷 Tags: #Android#Xposed#Modules

纯情男高

@hanzichen · Post #1400 · 28.11.2025 г., 00:25

AnghamiPlus AnghamiPlus is a sophisticated Xposed module that enhances your Anghami music streaming experience by unlocking plus-like features directly on the client side. Built with a modular and safe hooking architecture, it provides plus functionality without modifying server behavior or compromising your account security. 🔗 Links: - Download - Features - How to use - Support group and channel - Source code Developer: Kero309x ❤️ Support the Project If this project makes your life easier, here are a few quick ways to show some love: ⭐ Star the repo/app ☕ Buy a coffee for the developer 🛠 Contribute code, issues, or pull-requests ⚠️ This app might be breaking copyright laws, use at your own risk. We are not responsible for anything. We are just sharing open source software. 🏷 Tags: #Android#Music#Xposed#LSPatch#Modules

djangoproject

@djangoproject · Post #456 · 04.10.2017 г., 02:57

http://www.techbeamers.com/python-tutorial-essentials-of-python-socket-programming/ Essentials of Python #Socket Programming You Should Know Python offers two types of #API libraries that we can use for socket programming. At the low-level, Python utilizes the “socket” library to implement #client and #server#modules for both #connectionless and #connection-oriented #network protocols. Whereas, at the higher-level, You can use libraries like #ftplib and #httplib to interact with application-level network protocols like #FTP and #HTTP.

djangoproject

@djangoproject · Post #513 · 30.11.2017 г., 22:00

#AI#Artificial_Intelligence #AJAX #aiohttp #Anaconda #AngularJS #API #Atom #AWS #asyncio (#Asynchronous) #audio #automated_testing #automation #atexit #BeeWare #Big_Data #bitcoin #blockchain #Bluemix #Brython #button #Celery #client #class #classmethod #concurrency #Coroutine #cron #CSS #curl #data_analysis #data_mining #data_processing #database #Deep_Learning#deep_learning #Debian #decorator #deploy #dict #dispatch #django #django_cms #Django_REST_Framework #dropdownbox #Docker #event #Firefox #Flask #form #functions #Generator #GeoDjango #git #Google #GPU #GUI #Gym #host #HTML #httplib #learn #Image_processing #intelligence #input #Instagram #IOT #iPython #Jupyter #lambda #learn #License #Linux #lists #machine_learning #Magenta #map #Matplotlib #Metaprogramming #Micro_services #Micropython #mind #monitoring #MongoDB #modules #Mozilla #Multipart #multi_touch_apps #multiprocessing #Nodes #NoSQL #numeric_computation #numerical #NumPy #network #neural_network #OAuth #object_serialization #OCR #overloading #package #parallel #pipeline #protocols #PostGIS #pyAudioAnalysis #pycon #Pyflakes #PyInstaller #PyPI #PyQt #PySide #PyTorch #pytest #python #Pyvideo_archives #Qt #Raspberry_Pi #React #Redis #random #request #Regular_Expressions (#re) #REST #RSS #satellite #scikit_learn #SciPy #scrapy #searching #selectbox #Selenium #serialization #server #sessions #single_responsibility_principle #socket #Spark #str #submit #task #telegram #template #TensorFlow #test #text_boxes #text #tuples #unicode #Universe #Unix #unit_test #urllib #upload #uWSGI #Web #WSGI