mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
19 lines
294 B
Python
19 lines
294 B
Python
from pydantic import BaseModel
|
|
|
|
|
|
class BarModel(BaseModel):
|
|
whatever: int
|
|
|
|
|
|
class FooBarModel(BaseModel):
|
|
banana: float
|
|
foo: str
|
|
bar: BarModel
|
|
|
|
|
|
m = FooBarModel(banana=3.14, foo='hello', bar={'whatever': 123})
|
|
|
|
print(dict(m))
|
|
for name, value in m:
|
|
print(f'{name}: {value}')
|