2 ms·
Just mix this class in: class IWantToHaveNamedTupleInterfaceButWasToldTheyAreBad: def __iter__(self): return iter(self.__dict__.values(
by Joker_vD 2y ago
Just 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