On Sunday 30 November 2003 03:44 pm, Oren Tirosh wrote:
Instead of converting `expr` to repr(expr) convert it first to (`expr`) or even (`(expr)`) and make sure it still compiles into exactly the same bytecode. It should catch all the problem you mention except backticks in comments and strings. These need manual inspection.
I don't know if it should be *that* mechanical; there are a lot of places where I've seen " 'something %s' % repr(foo)" when I think it's much more clearly written as " 'something %r' % foo". I don't know which is the officially preferred style, but if it's the latter (and I hope it is ;)) then it may not be good to mechanically change backticks to a repr call.