▲ | ansgri 7 hours ago | ||||||||||||||||
If it’s 100x better than no types, then probably 10x better than C++ type system. It takes some time to unlearn using dicts everywhere, but then namedtuples become your best friend and noticeably improve maintainability. Probably the only place where python type system feels inadequate is describing json-like data near the point of its (de)serialization. | |||||||||||||||||
▲ | tecoholic 2 hours ago | parent | next [-] | ||||||||||||||||
There’s TyepdDict that is decent for a JSON like data structure if the types are simple. It doesn’t have the bells and whistles of Pydantic, but gets the job done for passing predictable dicts around and ensuring consistency while developing | |||||||||||||||||
▲ | rcfox 2 hours ago | parent | prev [-] | ||||||||||||||||
Pretty much anywhere you're tempted to use a namedtuple, you should be using a dataclass[0] instead. And typing JSON-like data is possible with TypedDict[1]. [0] https://docs.python.org/3/library/dataclasses.html [1] https://docs.python.org/3/library/typing.html#typing.TypedDi... | |||||||||||||||||
|