> 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?
>

I think this depends on the use case.

If the functions you're calling in between have a chance to be called
independently, then I would probably allow passing the documents in the
arguments, so that other code can utilise this function. On the other
extreme, if this function is only used internally, I would simply use
self.object to avoid copying extra references, and treat them as sub
routines. I would also previx two underscores (__) before the function to
indicate that it's supposed to be interal-use only.

The other use case is, if self.object is useful after the function, I would
keep it as that. Then, other code could use it without processing it again.
On the other hand, if it is useless after created and returned, then I would
not keep a reference in the class object.

All in all, you probably won't find a big performance difference, so it all
boils down to logical placement.

Cheers,
Xav
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to