Python script suddenly fails to compile with "expected an indent block" -


this script has been working fine, when go execute it, fails compile with:

  file "/users/camerongordon/desktop/python scripts/hello.py", line 12     def connecttodatabase():      ^ indentationerror: expected indented block 

here script:

import tornado.ioloop import tornado.web tornado.httpclient import asynchttpclient tornado import gen  tornado.options import define, options  apscheduler.schedulers.tornado import tornadoscheduler torndb import connection  class mainhandler(tornado.web.requesthandler):     def get(self):  def connecttodatabase():     db = connection("127.0.0.1", 'helloworld', user='root', password='')    return db  application = tornado.web.application ([     (r"/", mainhandler), ])  def processqueue:  def main():      # http://stackoverflow.com/questions/29316173/apscheduler-run-async-function-in-tornado-python     # https://github.com/teriyakichild/example-scheduler/blob/master/example_scheduler/__init__.py      application.listen(8888)      db = connecttodatabase()       scheduler = tornadoscheduler()      scheduler.add_job(processqueue, 'interval', name='tick-interval-3-seconds', seconds=4, timezone='america/chicago')      scheduler.start()      tornado.ioloop.ioloop.current().start()  if __name__ == "__main__":     main();  

what going on? looks syntactically correct , indented properly.

class mainhandler(tornado.web.requesthandler):     def get(self):  def connecttodatabase():     db = connection("127.0.0.1", 'helloworld', user='root', password='')    return db 

your def get(self): calls method body come; if add pass, things work. probably, accident, omitted or deleted code:

class mainhandler(tornado.web.requesthandler):     def get(self):         pass  def connecttodatabase():     db = connection("127.0.0.1", 'helloworld', user='root', password='')    return db 

also, indents unequal -- that's not sign. use proper editor.


Comments