MCPcopy Create free account
hub / github.com/bslatkin/effectivepython / from_row

Method from_row

example_code/item_065.py:101–105  ·  view source on GitHub ↗
(cls, row)

Source from the content-addressed store, hash-verified

99
100 @classmethod
101 def from_row(cls, row):
102 if len(row) != len(cls.fields):
103 raise ValueError("Wrong number of fields")
104 kwargs = dict(pair for pair in zip(cls.fields, row))
105 return cls(**kwargs)
106
107
108print("Example 5")

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected