On Apr 17, 5:56 pm, [EMAIL PROTECTED] wrote:
> class RequestHeadersManager:
>     ...
>     def __init__(self, headers, linesep):
>         headersDict = parse_headers(headers, linesep)
>
>         for header in headersDict.keys():
>         ...[lots of code]

Your code is pretty much equivalent to this (untested).

class RequestHeadersManager(object):
    def __getattr__(self, field):
        if not hasattr(self, field):
            return None
    def __init__(self, headers, linesep):
        for header, value in parse_headers(headers,
linesep).iteritems():
            header = '_'.join(x.capitalize() for x in
header.split('-'))
            setattr(self, header, value)

You may want to add some error checking though!

--
Paul Hankin
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to