On 21 October 2013 21:47, Terry Reedy <tjre...@udel.edu> wrote: > Manual says "-c <command> > Execute the Python code in command. command can be one or more > statements separated by newlines, with significant leading whitespace as in > normal module code." > > In Windows Command Prompt I get: > C:\Programs\Python33>python -c "a=1\nprint(a)" > File "<string>", line 1 > a=1\nprint(a) > ^ > SyntaxError: unexpected character after line continuation character > (Same if I remove quotes.) > > How do I get this to work?
By not using cmd.exe. On Windows I use "git bash" which I think is just bash from msys. If you find yourself spending any time using cmd.exe you'll appreciate why. I also use console2 as the GUI part of the terminal. In bash it's a simple matter of opening a single quote and then typing what you want including hitting enter (don't use single quotes in the Python code): $ python -c ' > a = 1 > if a: > print("a was true") > ' a was true Oscar -- https://mail.python.org/mailman/listinfo/python-list