i can't say i'm too fond of this, but i thought of bringing this up. most scripting
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 level:

e"[A-Za-z_][A-Za-z_0-9]*"

i thought of prefixing "e" for "regular *e*xpression". could also be "p" for pattern.
it's very simple -- regex literal strings are just passed to re.compile(), upon
creation, i.e.:
a = e"[A-Z]"

is the same as
a = re.compile("[A-Z]")

what is it good for?

if e"[A-Z]".match("Q"):
    print "success"

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 consideration.


-tomer
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to