Suggestion: Regex string specifier like r and f
Cameron Simpson
cs at cskk.id.au
Sun Jan 8 16:47:56 EST 2023
On 08Jan2023 12:44, Raphael Santiago <raphael.santiago.53 at gmail.com> wrote:
>Maybe something like re""
>It should behave exactly like a raw string but would be useful for syntax
>highlighting and debugging. Perhaps also for type hinting expected regex
>input (don't know if this is feasible).
A nice idea. (Though I'm personally reluctant to make regexps any
"easier" to use than they are already, a discussion for another thread.)
But the IDE/syntax help is cool.
There was discussion of essentially this idea just recently here:
https://discuss.python.org/t/allow-for-arbitrary-string-prefix-of-strings/19740
which you will find interesting.
I think it fizzled for 2 main reasons:
- string prefixes current have semantic meaning for the Python
parser/interpreter, while an artbitrary prefix ... doesn't
- "too hard"? to get IDEs to use it?
Of these, I only find the former compelling, and one could argue that
type annotations already form a "has no effect" syntax extension to
Python, so we're already in that playground :-)
Cheers,
Cameron Simpson <cs at cskk.id.au>
More information about the Python-list
mailing list