Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Mar 012010
 

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.

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>