[Python-Dev] Maintenance burden of str.swapcase

Glyph Lefkowitz glyph at twistedmatrix.com
Mon Sep 12 02:22:15 CEST 2011


On Sep 11, 2011, at 11:49 AM, Michael Foord wrote:

> Does anyone *actually* use .title() for this? (And why not just use the correct casing in the string literal...)

Yes.  Twisted does, in various MIME-ish places (IMAP, SIP), although not in HTTP from what I can see.  I imagine other similar software would as well.

One issue is that you don't always have a string literal to work with.  If you're proxying traffic, you start from a mis-cased header and you possibly need to correct it to a canonically-cased one.  (On at least one occasion I've had to use such a proxy to make certain buggy client software work.)

Of course you could have something like {b"CONNECTION-LOST": b"Connection-Lost", ...} somewhere at module scope, but that feels a bit sillier than just having a nice '.title()' method.

-glyph

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20110911/43e094bf/attachment.html>


More information about the Python-Dev mailing list