>>> re.sub("<", "<", "something < other")
'something < other'
which seems much more readable and consistent to me than s/a/b, though the s/ syntax is great for vim users like me.I don't think this has as much to do with your programming knowledge as your python knowledge?
In Python, much string manipulation is done with builtins (especially string methods) and library functions. The latter work especially well when you target a specific domain (such as HTML) and will often be implemented in regexps. Writing one's own regexps are for when you actually need a small custom state machine. Many problems are too small or too large to justify the effort.
Thanks for pointing out my error, and getting me to read the actual code instead of speculating. :)
Heheheh, boy would that get some bees in some bonnets on the Python dev ML. :)
http://dalkescientific.com/Python/python4ply-tutorial.html#p...
He presented it at PyCon a couple years ago, response seemed to be "that's cool".
A replacement on python looks like this...
foo = re.compile("<") bar = foo.replace(">", bar)
this works, but it just feels less awkward to me than
$bar = s/</>/