[Python-mode] compile problem in emacs
Peter Otten
__peter__ at web.de
Fri Feb 13 04:04:19 EST 2004
vissen at gmx.net wrote:
> i am new to Linux and Python.
Welcome to both!
>
> I get a syntax error for this line of code.
> .....
> def fib(n): # write Fibonacci series up to n
> ........
>
> used Emacs as the editor on a Redhat ver8.0 OS. (This example is included
> as part of tutorial/documentation in Python docs)
> any suggestions /ideas are useful.
> thanks for reading.
The code snippet is correct. Here's what your code *could* look like
<syntaxerror.py>
def test(
def fib(n): # write Fibonacci series up to n
"""Print a Fibonacci series up to n."""
a, b = 0, 1
while b < n:
print b,
a, b = b, a+b
</syntaxerror.py>
This will show the following slightly misleading syntax error:
File "<stdin>", line 3
def fib(n): # write Fibonacci series up to n
^
SyntaxError: invalid syntax
but I cannot be sure, because your post doesn't provide enough context.
In the future, please give a small but _complete_ example that shows the
erroneous/undesired behaviour and the _actual_ traceback (cut and paste
from emacs or the command line).
Peter
More information about the Python-list
mailing list