I wrote a library to do this a while back: <a href="http://panchekha.no-ip.com:8082/programming/minioperators.html" rel="nofollow">http://panchekha.no-ip.com:8082/programming/minioperators.ht...</a><p>Hope someone finds it useful, though to be honest, I don't think this sort of thing is very commonly useful.
Unfortunately this is not a "proper operator". For example, both sides need to be evaluated, so it cannot control the program flow.<p>Still, I really like the <i>inrex</i> module in the last comment. Great extension to the very clumsy <i>re</i>.
Clever hack. But this is one of the key differences between Python and Ruby. In Python, you're not <i>supposed</i> to hack the language like this. The benefit is that Python code remains readable without having to understand how the language has been "altered" in each specific project.<p>If you want to do this level of hacking with the language, why not just use Ruby?