@testflightynoti · Post #37689 · 07.05.2026 г., 06:38
#3D#Habits Join the 3D Habits beta on ✈️#TestFlight 🔗 Link: https://testflight.apple.com/join/GWsnkMXR Shared by Dimitri
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
Пребарај: #habits
@testflightynoti · Post #37689 · 07.05.2026 г., 06:38
#3D#Habits Join the 3D Habits beta on ✈️#TestFlight 🔗 Link: https://testflight.apple.com/join/GWsnkMXR Shared by Dimitri
Hashtags
@talks · Post #40 · 16.08.2016 г., 07:42
#Socrates#habits
@testflightynoti · Post #37844 · 08.05.2026 г., 10:41
#Harbor#Habits Join the Harbor Habits beta on ✈️#TestFlight 🔗 Link: https://testflight.apple.com/join/4tNnZWpc Shared by Dimitri
Hashtags
@testflightynoti · Post #37504 · 03.05.2026 г., 17:10
#init#Habits Join the init.Habits beta on ✈️#TestFlight 🔗 Link: https://testflight.apple.com/join/mtxQvGKU Shared by Dimitri
Hashtags
@googlefactss · Post #40613 · 31.01.2026 г., 23:01
As you may have noticed one month into the new year, traditional New Year’s resolutions often fail because people set vague or too big goals, rely only on willpower, and don’t have a clear plan. Small, specific changes and building habits step by step are supposed to work better. 🔄 [Read more] @googlefactss #NewYearsResolutions#Habits#Goals#SelfImprovement
@testflightynoti · Post #37690 · 07.05.2026 г., 06:38
#Flowly#Build#Better#Habits Join the Flowly : Build Better Habits beta on ✈️#TestFlight 🔗 Link: https://testflight.apple.com/join/16vbG1wU Shared by Dimitri
@googlefactss · Post #40880 · 30.03.2026 г., 22:01
Self-control is not just about willpower. 🧠 Building habits and routines makes it easier to stick to your goals. Repeating small positive actions regularly strengthens your ability to maintain self-discipline over time. Setting up your environment to make good choices easier and temptations harder also helps. After about three months, actions that once felt difficult can start to feel natural. 🔁🏃♂️🧩📊 [Read more] @googlefactss #psychology#selfcontrol#habits#goals#science#mindset If you have ideas or feedback contact us: @Googlefactss_Feedback_bot