[Python-Dev] Adding status code constants to httplib (original) (raw)

Phillip J. Eby pje at telecommunity.com
Fri Sep 10 17:01:08 CEST 2004


At 12:45 PM 9/10/04 +0100, Andrew Eland wrote:

Over in web-sig, we're discussing PEP 333, the Web Server Gateway Interface. Rather than defining our own set of constants for the HTTP status code integers, we thought it would be a good idea to add them to httplib, allowing other applications to benefit. I've uploaded a patch[1] to httplib.py and the corresponding documentation. Do people think this is a good idea?

I would also put the statuses in a dictionary, such that:

 status_code[BAD_GATEWAY] = "Bad Gateway"

This could be accomplished via something like:

 status_code = dict([
    (val, key.replace('_',' ').title())
        for key,val in globals.items()
            if key==key.upper() and not key.startswith('HTTP')
                and not key.startswith('_')
 ])


More information about the Python-Dev mailing list