S
s0suk3
Umm, doesn't defining all those members in the class lead to class
variables, not instance variables? I believe the recommended way of
making it clear what instance variables to expect is to initialize them
all in __init__. Currently in your implementation, each instance of
your class is going to share the same variables for all those fields you
defined, which probably isn't what you want.
consider:
class myclass(object):
classvar1=None
classvar2=None
def __init__(self,test):
self.instancevar1=test
6
Also, your idea of checking the length of the headers to reduce the
number of string comparisons is a great case of premature optimization.
First it does not clarify the code, making it harder to follow.
Second, since web servers are I/O bound, it likely does nothing to
improve speed.
So my recommendation is to use a bunch of self.HEADER_NAME=None
declarations in __init__(). This is the expected way of doing it and
all python programmers who are looking at your code will immediately
recognize that they are instance variables.
You didn't really write that at the Python's interpreter, did you?
It's wrong. The way that would really go at the interpreter is like
this:
.... classvar1=None
.... classvar2=None
.... def __init__(self,test):
.... self.instancevar1=test
....6
classvar1 and classvar2 might be class variables, but in they don't
work as they would in C++ or Java (like the ones you declare with the
'static' modified).