1

I'm practising python and recently this problem crept up when I have invalid syntax in a program, the error output in terminal from python is blank like so..

 python test.py 
    File "test.py", line 6

                                                                     ^
SyntaxError: invalid syntax
9
  • What is the question exactly? Commented Mar 6, 2012 at 14:05
  • 3
    Please post the code segment that is generating this error. It is impossible to help without the culprit code. Commented Mar 6, 2012 at 14:06
  • I guess he's asking how to fix the Python terminal so that it shows the code of the line that has error, and caret below the problem area. Commented Mar 6, 2012 at 14:07
  • What IDE do you use? E.g. Raw terminal under Linux? X11? IDLE? Commented Mar 6, 2012 at 14:07
  • All terminals are doing this for me, the code doesnt matter, if i leave out a ) in a print statement it displays like this Commented Mar 6, 2012 at 14:11

1 Answer 1

2

From the comments I gather that you are getting the error when leaving out the closing bracket of a function call.

The odd display is not a terminal error, Python does not raise a syntax error until it realizes that the bracket is not there, which can happen several lines below in your code as function calls are allowed to span multiple lines.

Here, you probably have something on the line (7) after the one where python raises a SyntaxError. Python expected a closing bracket before, so it highlights the very last character of the line before, which is the last valid spot for the (missing) bracket.

Sign up to request clarification or add additional context in comments.

1 Comment

you don't need a blank line, example. Notice that ^ points to the end of the comment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.