On 12/9/2013 3:36 PM, Logan Collins wrote:
Just checking whether 1) a PEP is the proper place for this

No, not needed. If, after discussion here (or python-ideas), such a change would only need a tracker issue.

and 2) what y'all think about it.

I would like to propose a change to the the 're' standard library to
support iterables.

Not really. You are proposing that re.sub accept an iterable of strings for the replacement string.

So, something like the following would work:

import re
text = """hello user
hello user
hello user"""

Repeating the text is the wrong approach. So is using re when not needed.

users = ["Bob", "Alice", "Jeffery"]

newtext = re.sub("user", users, text)

# newtext = "hello Bob\nhello Alice\nhello Jeffery"

>>> '\n'.join('Hello user'.replace('user', name) for name in ["Bob", "Alice", "Jeffery"])

'Hello Bob\nHello Alice\nHello Jeffery'

--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to