Tim Arnold a écrit :
Hi,
I have a few classes that manipulate documents. One is really a
process that I use a class for just to bundle a bunch of functions
together (and to keep my call signatures the same for each of my
manipulator classes).
So my question is whether it's bad practice to set things up so each
method operates on self.document or should I pass document around from
one function to the next?
As far as I'm concerned, I strongly prefer passing the document around.
Makes thing clear, avoids useless preconditions (is self.document set
???) and race conditions (if two threads have to share the Manipulator
instance), makes the code easier to understand / maintain / refactor IMHO.
Also remember that modules are objects too, so - depending on parts of
your code we don't see here - you may even maintain your API without
having to use a "class as module".
My 2 cents
--
http://mail.python.org/mailman/listinfo/python-list