title: Callback, observers, and asynch sockets in Python
body: <p>I'm still a neophyte Python programmer and I'm trying to do something that is a bit over my head.</p>
  
  <p>What I've done is create a simple IRC bot using asyncore (and asynchronous sockets module).  The client runs in a continuous loop, listening to the conversation in the channel.  What I would like to do (I think?) is implement an observer pattern so I can respond to events.  I imagine it would look somthing like this:</p>
  
  <pre><code>class MyBot(object):
  
     def __init__(self):
        bot = MyIRCClient(server='whatever', channel='#whatever')
        bot.observe(event='join', handler='log_join')
        bot.connect() # Bot is now listening continously in a loop
  
     def log_join(self, e):
        print e + ' joined the channel.'
  </code></pre>
  
  <p>I'm basing this design around what I know of observers used in the various Javascript frameworks.  I don't know if the same technique can or should be applied here.  Any suggestions?</p>