Can't do a multiline assignment!
D'Arcy J.M. Cain
darcy at druid.net
Thu Apr 17 12:33:35 EDT 2008
On Thu, 17 Apr 2008 09:19:32 -0700 (PDT)
s0suk3 at gmail.com wrote:
> I'm building a web server. The many variables are names of header
> fields. One part of the code looks like this (or at least I'd like it
> to):
>
> class RequestHeadersManager:
>
> # General header fields
> Cache_Control = \
> Connection = \
> Date = \
> Pragma = \
> Trailer = \
> Transfer_Encoding = \
> Upgrade = \
> Via = \
> Warning = \
>
> # Request header fields
> Accept = \
> Accept_Charset = \
> Accept_Encoding = \
> Accept_Language = \
> Authorization = \
> ...
>
> Etc etc etc. At the end they'll all be assign to None. Then, when
> initialized, __init__() will the the string of headers, parse them,
> and use those variables shown above to assign to the header values. Of
> course a normal request won't include all of those headers, so the
> others will remain None. That's what I want.
So basically you want a class that has a dict of headers which __init__
assigns to and to get a header you basically return O.get(header).
--
D'Arcy J.M. Cain <darcy at druid.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
More information about the Python-list
mailing list