Nxt-python-hints

From Earlham Cluster Department

Revision as of 13:14, 27 April 2010 by Nickm (Talk | contribs)
Jump to: navigation, search

Back to Robotics Main Page


Python Programming Hints

try:
  [your code here]
finally:
  [stop all your motors]
class thread_wait( threading.Thread ):
  def __init__( self, condition, action ):
     threading.Thread.__init__( self )
     self.condition = condition
     self.action = action
  
  def run( self ):
     while not self.condition():
         sleep(0.1)
     self.action

Usage:

kill_switch_thread = thread_wait( get_kill_switch_function, suicide_function )
kill_switch_thread.start()
Personal tools
Namespaces
Variants
Actions
websites
wiki
this semester
Toolbox