passing object between classes
duncan.booth at invalid.invalid
Tue Sep 22 09:40:27 CEST 2009
daved170 <daved170 at gmail.com> wrote:
> Is there any existing python Log object that do so?
There is. See Jean-Michel Pichavant's reply.
> I no, I created my
> own Log object that only open file and write a line to it,
> how can I make it be global?
You could assign it to a global name.
> Should I use it as a static object?
If you wish. It depends on exactly what you want. Usually static
objects are fine for logging unless you want to be able to modify the
logging in particular situations (e.g. when running your unit tests). In
that case you could just assign it to an attribute of your object much as
you were failing to do in your original post: there is no reason at all why
that shouldn't work also.
> will it work?
There is no reason why not.
> (offcurse in the case of the threads I'll use utex)
With the built-in logging module you don't need to worry about that.
Duncan Booth http://kupuguy.blogspot.com
More information about the Python-list