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

Резултати

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

Пребарај: #medicaldevices

当前筛选 #medicaldevices清除筛选
Venture Village Wall 🦄

@venturevillagewall · Post #3622 · 21.12.2024 г., 10:22

Sotelix Endoscopy Raises $1.7M Sotelix Endoscopy has successfully raised $1.70 million in funding as of December 19, 2024. For more information, visit their official site: Sotelix Endoscopy #Funding#Healthcare#MedicalDevices#Sotelix#Endoscopy#Investment#Startup#Innovation#Tech#Business

Venture Village Wall 🦄

@venturevillagewall · Post #3636 · 21.12.2024 г., 10:23

Cell Therapies Funded $7.4M Astraveus has raised $7.40M for its Lakhesys - The Benchtop Cell Factory®, aiming to enhance the accessibility of cell therapies for patients by December 19, 2024. 🔗Learn more here #Astraveus#Funding#CellTherapy#Healthcare#Biotech#Investment#Lakhesys#Therapies#Accessibility#MedicalDevices

Venture Village Wall 🦄

@venturevillagewall · Post #3415 · 18.12.2024 г., 12:11

Turn Therapeutics Secures $75M Funding Turn Therapeutics, specializing in advanced wound and dermatologic care, has raised $75 million in funding. The investment aims to boost their innovative pharmaceutical and medical device offerings using proprietary technology. For more details, visit their website: Turn Therapeutics. #Funding#Biotech#Healthcare#Pharmaceuticals#MedicalDevices#WoundCare#Dermatology#Investment#Innovation#Technology#TurnTherapeutics#Proprietary#AdvancedCare#Medical#Company#Therapeutics#Research#Development#Startups

Venture Village Wall 🦄

@venturevillagewall · Post #3629 · 21.12.2024 г., 10:22

$4.07M Funding for PeptiSystems PeptiSystems secured $4.07M in funding on December 20, 2024. The company develops advanced instruments for solid-phase synthesis in peptide and oligonucleotide therapeutics, catering to both GMP and non-GMP manufacturing. Discover more: PeptiSystems #Funding#PeptiSystems#Therapeutics#Peptides#Oligonucleotides#GMP#Manufacturing#Synthesis#Biotechnology#Pharmaceuticals#MedicalDevices#FlowthroughColumnTechnology#ProcessDevelopment#LifeSciences

Venture Village Wall 🦄

@venturevillagewall · Post #4091 · 07.02.2025 г., 13:00

February 2025 Funding Round Updates 🔶Ivo: $16M raised, streamlining agreement negotiations. 🔷Reservoir: $14M secured for efficient token market infrastructure. 🔶Azimuth: $13.75M for advanced PNT systems in navigation. 🔷SUPERBRANCHE: $13.43M investment in nanoparticle technologies for cancer treatment. 🔶Prior Labs: $9.37M to enhance data science with the TabPFN model. 🔷REEV: $9.20M for enhancing mobility in medical orthoses. 🔶Saeki Robotics: $6.70M to innovate autonomous manufacturing. 🔷Modern Synthesis: $5.50M for developing customizable circular textiles. 🔶PartsCloud: $5.21M to revolutionize spare parts fulfillment. Links to more details are available in each company’s profile. #Funding#Ivo#Reservoir#Azimuth#CancerTech#SUPERBRANCHE#DataScience#PriorLabs#MedicalDevices#REEV#Robotics#Saeki#Sustainability#ModernSynthesis#PartsCloud#VC#Crypto