On Dec 9, 2015, at 03:43, טל ח <[email protected]> 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
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com