Reputation: 4743
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?
Upvotes: 12
Views: 7103
Reputation: 206
I know this is an old post, but for those of you with similar issues in 2018 and later, CodeMix for Eclipse is a plugin you can install to boost your python development with almost none configuration needed. You get Content Assist, Validation, shortcut commands for stuff from refactoring to formatting, etc. More informaiton here
Upvotes: 3
Reputation: 2194
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.
Upvotes: 23
Reputation: 395085
I think it's possible you're actually using Python 2. Do this and report your results:
import sys
print(sys.version)
EDIT:
Actually, what you're reporting appears to be an open bug on pydev for Eclipse:
http://sourceforge.net/p/pydev/bugs/913/
Upvotes: 0
Reputation: 1
Change the run path in eclipse to python 3.x rather than its current setting which is probably set to python 2.x
Upvotes: 0
Reputation: 1460
In python 2.x print
is a built-in keyword, not a function as in python 3.x and is used like this :
>>> print "hello", "world"
hello world
Therefore, Python assumes that (r, end= '')
is a tuple containing two values, that you are trying to print.
You can probably configure eclipse to use python 3.x syntax. Check this if you are using PyDev.
Upvotes: 1