Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python code works, but eclipse shows error - Syntax error while detecting tuple

I new to python. I use Python 3.3 in Eclipse Kepler.

This is my code snippet:

f = Fibonacci(0,1)
for r in f.series():
    if r > 100: break
    print(r, end=' ')

At the line print(r, end = ''), eclipse reports a syntax error - Syntax error while detecting tuple. However, the program runs perfectly.

Why does this happen and how do I fix the error?

like image 793
Erran Morad Avatar asked Mar 18 '14 19:03

Erran Morad


People also ask

How do you fix a syntax error in Python?

You can clear up this invalid syntax in Python by switching out the semicolon for a colon. Here, once again, the error message is very helpful in telling you exactly what is wrong with the line.

How do I enable Python in eclipse?

Running Python from within Eclipse py, and Eclipse will recognize it as Python code. Type in some Python code (for instance: print 2+2 ), then right-click on the Python file you've created and select Run As >> Python run . You should see the output of your Python code in the console at the bottom of the Eclipse window.

Is Python compatible with Eclipse?

The first time we run a Python project, Eclipse will display the following Run As pop-up window. Click on Python Run and then click OK. Python will save the file for this module and then run its script; if there is no Console view in which to run the script. Eclipse will create a new one.

How do I get rid of Python not configured in Eclipse?

open eclipse application, click preferences click PyDev Click Interpreter Click Python Interpreter (below Figure 1) Click Choose from List button (below Figure 2) Select what ever Python version you want to use Click Apply Click OK Exit Eclipse ReOpen it and all fixed.


1 Answers

You need to specify the correct Grammar Version in Eclipse. See here: print function in Python3

Is Grammar Version 3.3 in your setup? Steps - Project > Properties > Python Interpreter/Grammar. You might have to restart Eclipse to see the changes.

like image 136
Roberto Avatar answered Sep 19 '22 15:09

Roberto