In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Aahz) 
wrote:

> In article <[EMAIL PROTECTED]>,
> Kent Johnson  <[EMAIL PROTECTED]> wrote:
> >D wrote:
> >>
> >> My question is, how would I go
> >> about creating the thread?  I have seen examples that used classes, and
> >> other examples that just called one thread start command - when should
> >> you use one over another?
> >
> >For simple use it doesn't matter. Use a class when you want to add more 
> >state or behaviour - for example you might want a flag that tells the 
> >thread to stop, or a Queue to communicate with the thread. A class might 
> >be more convenient in these cases.
> >
> >IOW if you can write it as a single function it doesn't matter much 
> >which form you use; for more complex usage you may want a class.
> 
> OTOH, always subclassing requires less thinking.

Same for never subclassing :)

I always felt that subclassing Thread is very unpythonic. It seems like 
an unfortunate leftover Javaism (much of threading.py was inspired by 
Java, but I don't need to tell you that). If I need some state, I create 
my own class, with a reference to the Thread object if needed. Has-a vs. 
is-a.

Just
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to