On 9/5/2011 7:18 PM, Steven D'Aprano wrote:
Terry Reedy wrote:
The doc says "-c<command>
Execute the Python code in command. command can be one or more
statements separated by newlines,"
However, I have no idea how to put newlines into a command-line string.
I imagine that it depends on the shell you are using, but bash on Linux
makes it simple: double quotes "..." are like Python's triple-quoted
strings in that they can include newlines.
[steve@sylar python]$ ls f*.py | python -c "import sys
print sys.stdin.read()"
factorial.py
fetchqm.py
I was guessing that whoever wrote the doc could do something like that.
As far as I know, there is no way to escape a newline with Windows
cmd.exe. (Someone please tell me if I am wrong!) An "unmatched" quote is
either ignored or matched by the newline!
C:\Programs\Python32> python -c "print('haha')
haha
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list