@learnrcrussian · Post #4290 · 02.03.2025 г., 10:00
Eсли бы блин с начинкой был человеком If a blin with a filling were a human ❓Which one would you prefer😉? Source: Pikabu #just_a_joke #Shrovetide #holidays 😎 Stay with @learnRCRussian
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
Пребарај: #shrovetide
@learnrcrussian · Post #4290 · 02.03.2025 г., 10:00
Eсли бы блин с начинкой был человеком If a blin with a filling were a human ❓Which one would you prefer😉? Source: Pikabu #just_a_joke #Shrovetide #holidays 😎 Stay with @learnRCRussian
Hashtags
@learnrcrussian · Post #4288 · 02.03.2025 г., 09:08
🇷🇺Some Russian spirit of Maslenitsa for you, comrades! Video photo:✈️grafynia #holidays #Shrovetide #memes 😎 Stay with @learnRCRussian
Hashtags
@learnrcrussian · Post #4285 · 01.03.2025 г., 14:00
В моём теле была лёгкость и энергия, двадцать блинов назад ... My body felt light and energetic, twenty pancakes ago... #just_a_joke #Shrovetide #holidays #memes 😎 Stay with @learnRCRussian
@learnrcrussian · Post #4284 · 01.03.2025 г., 12:00
🥞Russian Blini: A Quick Recipe Ingredients: ☆1 cup milk ☆1 cup flour ☆1 egg ☆1 tablespoon sugar ☆Pinch of salt ☆2 tablespoons melted butter (plus extra for greasing) Instructions: 1. Whisk together milk, egg, sugar, and salt. 2. Gradually add flour, whisking until smooth. 3. Stir in melted butter. 4. Let batter rest for 15-30 minutes. 5. Lightly grease a hot pan. 6. Pour 1/4 cup batter onto the pan for each blini. 7. Cook for 1-2 minutes per side, until golden brown. 8. Serve warm with your favourite toppings (sour cream, jam, red caviar). 💢 By the way: • Печь блины [pech bli-ny] doesn't only mean to bake blini but also to skip pebbles on the water. Did you know it? Video: AI Pinterest 😋Yummy! What's your favourite topping/filling for Russian blini? #Russian_cuisine #holidays #Shrovetide 😎 Stay with @learnRCRussian
@learnrcrussian · Post #4287 · 02.03.2025 г., 07:19
🌝С Масленицей! Happy Shrovetide! 🔻Maslenitsa (or Shrovetide), a week-long traditional Russian festival before Lent, culminates in Forgiveness Sunday. 🔻This significant day precedes Great Lent, marking a time for asking forgiveness and reconciliation. 🔻The week-long celebration leading up to it features the vibrant Russian tradition of Maslenitsa, including feasts, games like the thrilling greased pole climb, the burning of a winter scarecrow, and joyous performances of folk songs, lively chastushki (short humorous Russian songs), and energetic Russian folk dances. 🔻Maslenitsa remains incredibly popular, showcasing Russia's rich cultural heritage and is celebrated by Russians not only in Russia but in other countries as well. Video: an episode from Russian film Сибирский цирюльник by Nikita Mikhalkov (1998) #Maslenitsa #Shrovetide #holidays #Russian_culture #ForgivenessSunday 😎 Stay with @LearnRCRussian