Skip to content

How to perform syntax check for Python program

How to perform syntax check for Python program

Answer:

Assume you have a simple Python script hello.py, you want to perform syntax check. You can use the following method

# python -c 'import hello'

Traceback (most recent call last):
  File "", line 1, in 
  File "hello.py", line 1
    echo "Hello, World!"

If there is any syntax error, it will prompt out to the screen.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay
  1. How to perform syntax check for Perl program
  2. How to perform syntax check on a bash script?
  3. Perform syntax check to PHP files
  4. How to debug in Python?
  5. How to check the ./configure arguments used during last program compilation

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*