steven.bethard at gmail.com
Tue Aug 31 22:02:24 CEST 2004
Mike Maxwell <maxwell <at> ldc.upenn.edu> writes:
> python -c "print 'hi'; for i in [1,2]: print i"
> gives me an invalid syntax error, with the carat pointing to the end
> of the word 'for'.
Semicolons are only allowed with simple statements, not compound statements:
stmt_list ::= simple_stmt (";" simple_stmt)* [";"]
So that you can only join simple statements with ";" characters.
If you want to insert newlines, in unix, you can do this like:
> python -c "print 'hi'\
? for i in [1,2]:\
? print i"
Note that the '\' characters cause unix to include the newline in the string,
instead of reading it as the command terminator. I don't know how to do this
More information about the Python-list