Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I agree that namedtuples shouldn't be used if you don't actually want a tuple.


I concur :-)

Otherwise, use a dict, types.SimpleNamespace, python-attrs, or a custom class.

FWIW, the origin of namedtuple() was that some variation of it had been re-invented many times and this tool brought together the common features of those tools (substitutability for regular tuples, compact storage, usability as a dictionary key, named fields, a clear __repr__, etc.)




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: