Niko Gamulin
Niko Gamulin

Reputation: 66575

Running Tornado with Python 3.2

I just started out with Python and wanted to try out tornado.

Running the example from tornado website

import sys
sys.path.append(r'C:\Python32\tornado-2.3')

import tornado.ioloop
import tornado.web

class MainHandler(tornado.web.RequestHandler):
    def get(self):
        self.write("Hello, world")

application = tornado.web.Application([
    (r"/", MainHandler),
])

if __name__ == "__main__":
    application.listen(8888)
    tornado.ioloop.IOLoop.instance().start()

I got the following error:

File "C:\Python32\tornado-2.3\tornado\ioloop.py", line 302
except Exception, e:
                ^
SyntaxError: invalid syntax

I Installed Python 3.2 on Windows 7 machine.

Does anyone know what could be the cause for exception?

Upvotes: 0

Views: 693

Answers (1)

phihag
phihag

Reputation: 288270

In Python 3, you must use the as keyword., i.e.

except Exception as e:

Run

python3 setup.py build

in the C:\Python32\tornado-2.3 directory to generate a Python3 build (with 2to3) in tornado/build/lib.

Upvotes: 2

Related Questions