2 ms·
def __iter__(): yield self.my_field yield self.my_other_field Recreates tuple unpacking.
by doctorpangloss 2y ago
def __iter__():
yield self.my_field
yield self.my_other_field
Recreates tuple unpacking.
- Joker_vD 2y agoJust mix this class in: class IWantToHaveNamedTupleInterfaceButWasToldTheyAreBad: def __iter__(self): return iter(self.__dict__.values()) and voila: @dataclass(frozen=True) class Point(IWantToHaveNamedTupleInterfaceButWasToldTheyAreBad): x: int y: int p = Point(1, 2) x, y = p
- heavyset_go 2y agoYes, but that is insane.