[Python-3000] regex literals?
tomerfiliba at gmail.com
Tue Aug 29 21:43:57 CEST 2006
i can't say i'm too fond of this, but i thought of bringing this up. most
languages (perl, ruby, and boo, to name some) have regular expressions as
language literals. since such languages are heavily used for string
manipulation, it might seem like a good idea to add them at the syntax
i thought of prefixing "e" for "regular *e*xpression". could also be "p" for
it's very simple -- regex literal strings are just passed to re.compile(),
a = e"[A-Z]"
is the same as
a = re.compile("[A-Z]")
what is it good for?
since strings (as well as regex strings) are immutable, the compiler can
re.compile them at compile time, as an optimization.
again, i can't say i'like regex literals, and i don't think it would be a
productivity boost (although you would no longer need to import re and
re.compile() your patterns)... but i wanted to bring it to your
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-3000