Anyone understand this syntax error?

Peter Otten __peter__ at web.de
Sun Dec 3 02:57:27 EST 2006


Sean Hammond wrote:

> 
> Anyone understand this?
> 
> Python 2.4.4c1 (#2, Oct 11 2006, 21:51:02)
> [GCC 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> def markdown_perl(input):
> ...     """Send 'input' (string) to the markdown perl script, and return
> the
> ...        output from markdown (string).
> ...
> ...        input: a string of markdown-formatted text, including \n's at
> the end
> ...               of lines, that will be sent to the markdown process.
> ...
> ...        returns: a string of valid XHTML from markdown
> ...        """
> ...     import tempfile
> ...     import commands
> ...     file = tempfile.NamedTemporaryFile()
> ...     file.write(input)
> ...     file.flush()
> ...     return commands.getoutput('./markdown.pl '+file.name)
>    File "<stdin>", line 15
>      return commands.getoutput('./markdown.pl '+file.name)
>      ^
> SyntaxError: invalid syntax
>>>>
> 
> I don't get it. Syntax seems fine to me, just a normal string
> concatenation.
> 
> --

Are you perhaps mixing tabs and spaces?

>>> def f():
...     print "hello" # four spaces before 'print'
...     return 42     # one tab before 'return'
  File "<stdin>", line 3
    return 42
    ^
SyntaxError: invalid syntax

Peter



More information about the Python-list mailing list