3 ms·
I think Python's "named tuple" is an interesting middle approach. It allows a somewhat-descriptive collection of data fields that has the benefits of a class w
by makecheck 10y ago
I think Python's "named tuple" is an interesting middle approach. It allows a somewhat-descriptive collection of data fields that has the benefits of a class without requiring quite as much effort to create. Therefore, a Python named tuple has some immediately-obvious benefits (unlike the C++ std::tuple<>, whose benefits are FAR less clear).
Off the top of my head, the main value in tuple<> would be to greatly simplify the effort of implementing certain operators in a class, such as less-than.