A critique of cgi.escape

Max M maxm at mxm.dk
Mon Sep 25 10:00:45 EDT 2006


Fredrik Lundh skrev:
> Jon Ribbens wrote:

>> By the way, if you could try and put across your proposed arguments as
>> to why you don't favour this suggested change without the insults and
>> general rudeness, it would be appreciated.
> 
> I've already explained that, but since you're convinced that your use
> case is more important than other use cases, and you don't care about
> things like stability and respect for existing users of an API, nor
> the cost for others to update their code and unit tests, I don't see
> much need to repeat myself.  Breaking things just because you think
> you can simply isn't the Python way of doing things.


This thread is highly entertaining but perhaps not that productive.


Lawrence is right that the escape method doesn't work the way he expects 
it to.

Rewriting a library module simply because a developer is surprised is a 
*very* bad idea. It would break just about every web app out there that 
uses the escape module and uses testing. Which is probably most of them. 
That could mean several man years of wasted time. It also makes the 
escaped html harder to read for standard cases.

Frederik is right that doing so is utterly ... well let us call it 
"unproductive". Stupid is such a harsh word ;-)

Whether someone finds the bloat miniscule and thus a small enough change 
to warrant the rewrite does not really matter.

Lawrence is free to write a wrapper and use that instead.

     my_escape = lambda st: cgi.escape(st, 1)

So. Lawrence is happy, and the escape works as expected. Several man 
years has been saved.

Max M



More information about the Python-list mailing list