> On the other hand, it might be an indication that a tuple is the wrong tool 
> for the job.

1. It's not. The original tuple is not being mutated. And it may be desirable 
to enforce that immutability at the type level. Hence the choice of tuple 
rather than, say, list.

2. The same "objection" would apply to namedtuple._replace, since namedtuple is 
also immutable.

> As noted, a namedtuple DOES allow you to replace one component, and to do so 
> by name rather than knowing its index, so possibly that would be a better 
> choice here.

Tuples don't have names. They have indices.

The tuple equivalent of a namedtuple fieldname is an index.

And that's precisely what's being used here.

------- Original Message -------

On Thursday, March 10th, 2022 at 11:13 PM, Chris Angelico <ros...@gmail.com> 
wrote:

> On Fri, 11 Mar 2022 at 14:36, Jeremiah Vivian
>
> nohackingofkrow...@gmail.com wrote:
>
> > > See Python's "batteries included" philosophy.
> > >
> > > If users find themselves re-implementing the same utility function over 
> > > again and over again across different projects, it's a good sign that 
> > > such a function should be part of the standard library.
> > >
> > > Also something I agree with. What this method does is done a lot of times 
> > > and it could be made a little more readable by making it into an actual 
> > > method.
>
> On the other hand, it might be an indication that a tuple is the wrong
>
> tool for the job. As noted, a namedtuple DOES allow you to replace one
>
> component, and to do so by name rather than knowing its index, so
>
> possibly that would be a better choice here.
>
> 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/AHBORWEWN26RS7KWUFUJLRLRCE53RFIB/
>
> Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________
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/TCDUJWHTQ6C74E4EBEMVYWRJNW5D2RIM/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to