from pydantic import BaseModel, Field from uuid import UUID, uuid4 class item(BaseModel): name : str price : float item_id : UUID = Field(default_factory = uuid4) items = [] for i in range(3): items.append(item(name = 'test', price = 20)) print(items)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter