0

I'm new to using a lib called pydantic. They use syntax which is foreign to me, and have never seen this before. This is snippet which shows ":" much like a dict in an assignment statement. See the class FooBar and class MainModel for several instances. Would someone please enlighten me? Thanks.

class FooBar(BaseModel):
    count: int
    size: float = None

class Gender(str, Enum):
    male = 'male'
    female = 'female'
    other = 'other'
    not_given = 'not_given'

class MainModel(BaseModel):
    """
    This is the description of the main model
    """
    foo_bar: FooBar = Field(...)
    gender: Gender = Field(None)
    snap: int = Field(
        42,
        title='The Snap',
        description='this is the value of snap',
        gt=30,
        lt=50,
    )
Bill
  • 653
  • 2
  • 7
  • 20

0 Answers0