@Architecture_World · Post #6810 · 20.09.2021 г., 07:30
#facade by dmytrosolovyov
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
Пребарај: #facade
@Architecture_World · Post #6810 · 20.09.2021 г., 07:30
#facade by dmytrosolovyov
Hashtags
@arch_shovel · Post #586 · 17.08.2022 г., 06:31
Good morning by Maria Castello Martinez Architect #arch_shovel#architecture#archdaily#facade#facadedesign
@arch_shovel · Post #613 · 30.08.2022 г., 19:10
Chybik kristof unveils a newly designed private art gallery, defined by its shimmering facade of moveable copper tiles. the cluster of vertical cylinders are animated by the dynamic skin, which will gradually transform with a patina over time. Visualization: monolot.studio #rendering#cgi#facade#architect#archidaily#arch_shovel
@arch_shovel · Post #510 · 07.07.2022 г., 15:41
Mood of the day. Nhow Hotel. Image by Proloog Architecture: OMA #3d#render#archviz#visualization#architecture#facade#building#arch_shovel
@arch_shovel · Post #723 · 03.10.2022 г., 14:48
Happy World Architecture Day! Visualization: Plo.mp Project: Mixed-Use Complex with Kohn pedersen fox . #rendering#facade#architect#archidaily#minimalist#detail#architecturelover#arch_shovel
@arch_shovel · Post #746 · 15.10.2022 г., 19:50
B U B B L E H O U S E / Cheng Dong. A coherent city / Sangu Design The Human Condition by Hannah Arendt says that world is like a table that brings people together and separates people from each other. People yearn to see each other in the city; they call for a new connection which is beyond age, experience, boundaries, it also can transcend personal loneliness and urban barriers. . When the architect design and construct from the perspective of the user, they therefore are willing to respect the vitality of the building and rationally make use of the existing rules and conditions to practice the possibility of the local urban lifestyle. #facade#elevation#interior#urbanplan#geometricarchitecture#glassfacade#interiordesign#composition#modulararchitecture#building#arch_shovel