See the following Sourcegraph query for examples of use of this pattern:
https://sourcegraph.com/search?q=context:global+lang:python+%5C%5B%5Cs*:%5Cs*%28i%7Cj%7Ck%7Cind%7Cindex%29%5Cs*%5C%5D%5Cs*%5C%2B%5Cs*%5C%28.*%5C%2C%5C%29%5Cs*%5C%2B%5Cs*%5B%5Cw%5C.%5D%2B%5C%5B%5Cs*%28i%7Cj%7Ck%7Cind%7Cindex%29%5Cs*%5C%2B%5Cs*1%5Cs*:%5Cs*%5C%5D&patternType=regexp
Regex:
\[\s*:\s*(i|j|k|ind|index)\s*\]\s*\+\s*\(.*\,\)\s*\+\s*[\w\.]+\[\s*(i|j|k|ind|index)\s*\+\s*1\s*:\s*\]
------- Original Message -------
On Wednesday, March 9th, 2022 at 10:42 PM, wfdc <w...@protonmail.com> wrote:
> Add a "replace" method to tuples that returns a new tuple with the element at
> a given index replaced with a given value. Example implementation:
>
> def replace(self, index, value):
> return self[:index] + (value,) + self[index + 1:]
>
> See
> https://stackoverflow.com/questions/11458239/how-to-change-values-in-a-tuple
> for more context.
>
> Currently, tuples have 2 public methods: index and count. replace would be
> similarly easy to implement and similarly useful.
>
> Furthermore, it would be a natural counterpart to nametuple's _replace method.
_______________________________________________
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/AJ6HIDCV7JDSVFHUDU5444ZZ5KVR7SNI/
Code of Conduct: http://python.org/psf/codeofconduct/