title: Webpy: how to auto reload source code when it changed?
body: <p>I'm learning webpy to write code. 
  I'm using Webpy framework 0.34. my operating system is ubuntu 11.04 and python's version is 2.7.
  in webpy.org 's <a href="http://webpy.org/docs/0.3/tutorial" rel="nofollow">tutorials</a> it saids: </p>
  
  <blockquote>
    <p>"When running with the built-in webserver, it starts the application
    in debug mode. In debug mode any changes to code and templates are
    <strong>automatically reloaded</strong>"</p>
  </blockquote>
  
  <p>but it doesn't work. </p>
  
  <p>my code.py is the same as the tutorial's sample:</p>
  
  <pre><code>#!/usr/bin/env python
  # -*- coding: utf-8 -*-
  
  import web
  class index():
      def GET(self):
          return 'a'
  
  if __name__ == '__main__':
      urls = ('/', 'index')
      app = web.application(urls, globals())
      app.run()
  </code></pre>
  
  <p>and I am using the build-in webserver(used</p>
  
  <pre><code>python code.py
  </code></pre>
  
  <p>to start the server)</p>
  
  <p>when I change the code "return 'a'" to "return 'b'", in web browser, it keeps displaying 'a', untill I restart the server.</p>
  
  <p>restart server every time you rewrite the code is wasting time, why autoreload mechanism does not work? Am I doing something wrong? thank you for any help.</p>
  
  <hr>
  
  <p><strong>edit</strong>: sorry, my code.py is not exactly the same as the tutorial's sample, that cause the problem. if I put the urls assignment line outside the if statement, the reload mechanism works!!</p>
  
  <pre><code>#!/usr/bin/env python
  # -*- coding: utf-8 -*-
  
  import web
  
  class index():
      def GET(self):
          return 'a'
  
  urls = ('/', 'index')
  
  if __name__ == '__main__':
      app = web.application(urls, globals())
      app.run()
  </code></pre>
  
  <p>but I don't know why...</p>