On Sat, 12 Mar 2022 at 07:38, wfdc <w...@protonmail.com> wrote: > > > you haven't shown us what your use-case actually is > > Any use-case where you'd want to modify an entry of an immutable sequence.
That doesn't answer the question any more than your original code does. You're still starting with the assumption that you want to use a tuple, and using that as proof that you need to use a tuple. Show us your ACTUAL use case, your actual code, and why you can't use either a list or a namedtuple. Stop assuming that you are correct before you begin, because *we don't agree* that a tuple is necessary. You have not shown us any code, only made this repeated assertion and then wondered why we don't believe you. > Modifying an immutable datastructure is not a contradictory statement. In > fact, there's a whole literature on it. See > https://en.wikipedia.org/wiki/Purely_functional_data_structure > https://en.wikipedia.org/wiki/Persistent_data_structure Yes, and dataclasses and namedtuples support this concept very nicely. You still haven't shown why neither works. > As Marco Sulla pointed, out, "Performance apart, this will allow you to code > in functional style more easily." > > namedtuple's ._replace method is an existing example (as is record updating > in Haskell, which is a purely functional language, with the attending > benefits of immutability). > > For me *specifically*, my latest use-case is in a game-theoretic setting > where the tuple represents a strategy profile. But the details of that would > take us far beyond the scope of the discussion. I don't understand how a strategy profile has to be a tuple. In fact, particularly since you're wanting to replace one part of it, it definitely seems like a good use-case for a dataclass. > > whether it would actually be more appropriate for a list instead > > Lists are not immutable, so they fail the criteria. Why? Do you see how you are still failing to show any actual code, and thus any actual demonstration of why a tuple is necessary? Repeatedly stating that it has to be immutable, has to not be a namedtuple, has to not be a dataclass, and has to have a replace method, doesn't make it true. ChrisA _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/6MZTLI4I42ZEDJATKM5WDYHMSNEOW6IH/ Code of Conduct: http://python.org/psf/codeofconduct/