[Python-ideas] string.replace should accept a list as a first argument

Random832 random832 at fastmail.com
Wed Oct 7 02:49:21 CEST 2015


"Sven R. Kunze" <srkunze at mail.de> writes:

> On 06.10.2015 18:37, Ryan Gonzalez wrote:
> The OP has a list, not a string. Yes, he could create one by
> '|'.join(['undesirable', 'filthy']) but that's like:
>
> "Hey, I have some structured data, let's create some applesauce and
> have a secondary parser re-create structured data from it." IMHO that
> feels wrong.

Not sure how to get around that, other than by creating a general
"structured regex" module, to build a compiled regex from an abstract
regex syntax tree rather than a string. Which actually might not be the
worst thing in the world. I think there are some Lisp dialects that have
something like that.


More information about the Python-ideas mailing list