@ncdcgov · Post #4380 · 16.09.2024 г., 08:18
What is #diphtheria❓ Who is most at risk of getting infected❓ What are the signs and symptoms of #diphtheria infection❓ Watch & share 👇🏼 🔗https://youtu.be/6ZAgfCBDh0c?feature=shared
Hashtags
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
Пребарај: #diphtheria
@ncdcgov · Post #4380 · 16.09.2024 г., 08:18
What is #diphtheria❓ Who is most at risk of getting infected❓ What are the signs and symptoms of #diphtheria infection❓ Watch & share 👇🏼 🔗https://youtu.be/6ZAgfCBDh0c?feature=shared
Hashtags
@ncdcgov · Post #4260 · 19.04.2024 г., 09:23
Share Facts NOT Fear❗ 🔗Visit our website for accurate information on #diphtheria and to stay informed! ➡️Factsheet: https://ncdc.gov.ng/diseases/info/D ➡️Public health advisory: https://ncdc.gov.ng/news/435/diphtheria-public-health-advisory-amidst-outbreak-in-nigeria ➡️Healthcare workers advisory: https://ncdc.gov.ng/news/436/diphtheria-health-advisory-for-health-care-workers-amidst-outbreak-in-nigeria ➡️Situation reports: https://ncdc.gov.ng/diseases/sitreps/?cat=18&name=An%20Update%20of%20Diphtheria%20Outbreak%20in%20Nigeria
Hashtags
@ncdcgov · Post #4258 · 17.04.2024 г., 14:10
Q: How does #diphtheria spread? A: #Diphtheria spreads easily through: ➡️Direct contact with infected people ➡️Droplets from an infected person while coughing or sneezing ➡️Contact with contaminated objects/clothing For more FAQs, watch 👇🏼 & share: 🔗 https://youtu.be/6ZAgfCBDh0c
Hashtags
@ncdcgov · Post #4253 · 15.04.2024 г., 07:59
Individuals with symptoms suggestive of #diphtheria should report to a healthcare facility immediately for diagnosis and proper treatment. Ensure you take extra precautionary measures while visiting to prevent the risk of spread. Watch & share 👇🏼 🔗https://youtu.be/6ZAgfCBDh0c?feature=shared
Hashtags
@ncdcgov · Post #4237 · 30.03.2024 г., 09:26
Individuals with symptoms suggestive of #diphtheria should report to a healthcare facility immediately for diagnosis and proper treatment. Ensure you take extra precautionary measures while visiting to prevent the risk of spread. Watch & share 👇🏼 🔗https://youtu.be/6ZAgfCBDh0c?feature=shared
Hashtags
@ncdcgov · Post #4236 · 29.03.2024 г., 09:03
Q: How does #diphtheria spread? A: #Diphtheria spreads easily through: ➡️Direct contact with infected people ➡️Droplets from an infected person while coughing or sneezing ➡️Contact with contaminated objects/clothing For more FAQs, watch 👇🏼 & share: 🔗 https://youtu.be/6ZAgfCBDh0c
Hashtags
@ncdcgov · Post #4233 · 27.03.2024 г., 09:14
Q: Who is at risk of #diphtheria infection? A: ➡️Children & adults who are unvaccinated or partially vaccinated with the anti-diphtheria vaccine ➡️Individuals who live in crowded or dirty environments ➡️Healthcare workers For more FAQs, watch & share👇🏼 https://youtu.be/6ZAgfCBDh0c
Hashtags
@ncdcgov · Post #4230 · 23.03.2024 г., 08:51
What is #diphtheria❓ Who is most at risk of getting infected❓ What are the signs and symptoms of #diphtheria infection❓ Watch & share 👇🏼 🔗https://youtu.be/6ZAgfCBDh0c?feature=shared
Hashtags
@ncdcgov · Post #4137 · 22.12.2023 г., 08:13
Individuals with symptoms suggestive of #diphtheria should report to a healthcare facility immediately for diagnosis and proper treatment. Ensure you take extra precautionary measures while visiting to prevent the risk of spread. Watch & share 👇🏼 🔗https://youtu.be/6ZAgfCBDh0c?feature=shared
Hashtags
@ncdcgov · Post #4136 · 21.12.2023 г., 08:43
What is #diphtheria? Who is most at risk of getting infected? What are the signs and symptoms of #diphtheria infection? Watch & share 👇🏼 🔗https://youtu.be/6ZAgfCBDh0c?feature=shared
Hashtags
@ncdcgov · Post #4134 · 18.12.2023 г., 15:52
Q: How does #diphtheria spread? A: #Diphtheria spreads easily through: ➡️Direct contact with infected people ➡️Droplets from an infected person while coughing or sneezing ➡️Contact with contaminated objects/clothing For more FAQs, watch 👇🏼 & share: 🔗 https://youtu.be/6ZAgfCBDh0c
Hashtags
@ncdcgov · Post #4131 · 15.12.2023 г., 08:28
Q: Who is at risk of #diphtheria infection? A: ➡️Children & adults who are unvaccinated or partially vaccinated with the anti-diphtheria vaccine ➡️Individuals who live in crowded or dirty environments ➡️Healthcare workers For more FAQs, watch & share👇🏼 https://youtu.be/6ZAgfCBDh0c
Hashtags