mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
e7227db41a
* starting insert prints * working exec_script * remove prints, fix exec_examples.py * more cleanup of examples, better model printing * upgrade netlify runtime * extra docs deps * few more small tweaks
21 lines
420 B
Python
21 lines
420 B
Python
from datetime import datetime
|
|
from typing import List
|
|
from pydantic import BaseModel
|
|
|
|
class User(BaseModel):
|
|
id: int
|
|
name = 'John Doe'
|
|
signup_ts: datetime = None
|
|
friends: List[int] = []
|
|
|
|
external_data = {
|
|
'id': '123',
|
|
'signup_ts': '2019-06-01 12:22',
|
|
'friends': [1, '2', 3.1415]
|
|
}
|
|
user = User(**external_data)
|
|
print(user.id)
|
|
print(repr(user.signup_ts))
|
|
print(user.friends)
|
|
print(user.dict())
|