Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

def main() Invalid Syntax, Dev Server & Terminal

Tags:

python

syntax

From terminal:

File "index.py", line 41
def main():
  ^ SyntaxError: invalid syntax

From App Engine dev server. I'm running 2.7.3rc2 on Debian:

msg = 'invalid syntax'
      offset = 3
      print_file_and_line = None
      text = 'def main():\n'

Script:

def main():   # << here
    run_wsgi_app(application)

if __name__=="__main__":
    main()
like image 207
p1nesap Avatar asked Jun 13 '12 22:06

p1nesap


1 Answers

This error is probably being caused by a syntax error higher up in the code, like a missing close paren.

For example the following code will give a SyntaxError in the same place as your code:

(
def main():
    pass

If you are having a hard time tracking it down, post some of the code that comes earlier.

like image 53
Andrew Clark Avatar answered Sep 18 '22 13:09

Andrew Clark