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

Пребарај: #genetherapy

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

@venturevillagewall · Post #3846 · 11.01.2025 г., 10:00

Funding Rounds Boost Healthcare & Energy Sectors Several companies have recently secured significant funding: - Arizona Public Service: $1.81B, Jan 8, 2025. - Nephron Pharmaceuticals: $350M, Jan 10, 2025. - Windward Bio: $200M, Jan 10, 2025. - Timberlyne Therapeutics: $180M, Jan 10, 2025. - Hippocratic AI: $141M, Jan 9, 2025. - Ouro Medicines: $120M, Jan 10, 2025. - Movement Labs: $100M, Jan 8, 2025. - Rhygaze: $86M, Jan 10, 2025. - Light Horse Therapeutics: $62M, Jan 9, 2025. - Overhaul: $55M, Jan 10, 2025. - Numab: $54.94M, Jan 9, 2025. - Harsoria Healthcare: $20M, Jan 9, 2025. - Huazhi Energy: $13.64M, Jan 8, 2025. - Lava Network: $12M, Jan 9, 2025. - Pakistan Refinery Ltd: $11.24M, Jan 8, 2025. Find detailed updates on respective company websites for more insights. #Funding#Healthcare#Biotech#Energy#Pharmaceuticals#AI#Tech#GeneTherapy#Blockchain#VentureCapital#Investment

Venture Village Wall 🦄

@venturevillagewall · Post #3391 · 18.12.2024 г., 12:09

Concinnity Genetics Secures $3.79M Concinnity Genetics has raised $3.79 million in funding as of December 16, 2024. The company specializes in RNA-based gene control systems, aimed at enhancing the precision and safety of gene therapies. #Funding#GeneTherapy#RNA#ConcinnityGenetics#Biotech#Healthcare#Innovation

Venture Village Wall 🦄

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

$60M Funding for Psioxus Psioxus Therapeutics has successfully secured $60M in funding as part of its latest round, scheduled for December 17, 2024. This funding aims to advance its innovative tumor gene therapy platform focused on improving cancer treatment outcomes. #Funding#Cancer#Biotech#Oncology#GeneTherapy#Therapeutics#ClinicalStage#Investment#Healthcare#Psioxus#AkamisBio#Tumor#LifeScience#MedicalResearch#Therapy#Innovative#Impact#Technology#Platform