[Python-ideas] Binary f-strings

Chris Angelico rosuav at gmail.com
Fri Oct 2 16:52:23 CEST 2015


On Sat, Oct 3, 2015 at 12:48 AM, João Bernardo <jbvsmo at gmail.com> wrote:
>> But some of the other arguments are making me think bf'' is a bad idea,
>> so now I'm leaning towards not implementing it.
>>
>
> What about rf''? (sorry for being off topic here)
>
> Regex could benefit from it:
>
> my_regex = rf"ˆ\w+\s*({'|'.join(expected_words)})$"
>

Works fine:

rosuav at sikorsky:~$ python3
Python 3.6.0a0 (default:48943533965e, Sep 28 2015, 11:27:38)
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> expected_words = ["foo", "bar"]
>>> my_regex = rf"ˆ\w+\s*({'|'.join(expected_words)})$"
>>> print(my_regex)
ˆ\w+\s*(foo|bar)$
>>>

ChrisA


More information about the Python-ideas mailing list