On Sat, 12 Mar 2022 at 06:33, wfdc via Python-ideas
<python-ideas@python.org> wrote:
>
> > But *humans* can be confused by "replace" having a totally different API in 
> > different contexts.
>
> I doubt that's the case here.
>
> The closest equivalent to tuple's .replace method would be namedtuple's 
> _.replace method, which also has a different API from string's .replace 
> method.
>
> > I could (I believe) write "count" as an (inefficient) 1-liner, but not 
> > "index". I suggest it's harder than you think. (Try it!)
>
> How much harder? Can you post your candidate?
>
> In any case, my point still stands.
>
> >  "Not every 1-line function needs to be a built-in".
>
> Not every 1-line function needs to *not* be a built-in.
>
> > Well, you are 1 user. Have you evidence that there are (many) others?
>
> See the StackOverflow link and the 2 other participants in this thread who 
> attested to frequent use of this functionality.
>

You still haven't shown why a namedtuple is wrong for your use-case.
In fact, you haven't shown anything of your use-case, other than that
you've written a one-liner and wish that it were a method. What is the
larger context in which this is such an incredibly common operation?

In fact, if it's really such a frequent need, maybe you and/or other
participants can show more than one use-case. That would be helpful in
understanding why tuples need this as a method.

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/H7VCIVQD7EKM426G4PI6TU6JWLFP3POR/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to