A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2015-December/142427.html below:

[Python-Dev] A function for Find-Replace in lists

[Python-Dev] A function for Find-Replace in listsAndrew Barnert abarnert at yahoo.com
Wed Dec 9 11:47:42 EST 2015
On Dec 9, 2015, at 03:43, טל ח <talh555 at walla.co.il> wrote:
> 
> Hi,
> 
> I think it could be helpful for everyone if the function proposed by user "SomethingSomething" can be added as built-in
> in Python

Why? When he was asked what use it might have, he didn't have an answer.

Also, notice that the answer he provided doesn't actually do what he asked for; as he himself points out, it's different in at least two ways from his stated requirements. So, which one of the two do you want? And why is that one, rather than the other, useful?

Also, why would you call this list_replace? That sounds like a function that would replace elements with elements, not make a copy with elements replaced by new lists flattened into place.

Also, why would you only want this lists, rather than for any iterable? And what can it do that this more general and completely trivial function can't:

    def flattening_subst(iterable, value, sequence):
        for x in iterable:
            if x == value: yield from sequence
            else: yield x

If you know of another language whose standard library has an equivalent, that might narrow down exactly what the requirements are, point at an implementation that actually meets those requirements, and probably provide examples that hint at the point of having this function in the first place.


> See both question by "SomethingSomething" and answer to himself with implementation..
> 
> http://stackoverflow.com/questions/34174643/python-find-replace-on-lists
> 
> 
> Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20151209/56c413ba/attachment.html>
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4