[docs] [issue11073] threading.Thread documentation can be improved

Roy Smith report at bugs.python.org
Mon Jan 31 14:19:15 CET 2011


Roy Smith <roy at panix.com> added the comment:

Here's the code I ended up writing:

class Foo():
   def __init__(self):
       self.thread = Thread(target=Foo.runner, args=[self])
       self.thread.start()

   @staticmethod
   def runner(self):
      # blah, blah, blah

It was not immediately clear from the documentation if my runner() method should be declared static or not.  In retrospect, it must be (since this can be used with target functions which are not class methods at all), but it took a bit of thought to get from what the documentation said (i.e. 'callable object to be invoked by the run() method') to that conclusion.  

It seems to me the documentation could be a bit more explicit that your target does not get called as a method of some object.  Changing the text to read, "static function or other callable object" would remove any such confusion.

It could be that some of my confusion is due to my previously working with a C++ threading package where the thread runner functions *were* class methods.  Still, it seems like the potential for other people to be similarly confused exists and a little tweaking of the documentation text would help.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11073>
_______________________________________


More information about the docs mailing list