Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #57212

Re: python -c commands on windows.

Date 2013-10-21 17:56 -0400
From Ned Batchelder <ned@nedbatchelder.com>
Subject Re: python -c commands on windows.
References <l443sd$er5$1@ger.gmane.org>
Newsgroups comp.lang.python
Message-ID <mailman.1326.1382392599.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 10/21/13 4:47 PM, Terry Reedy 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?
>
You could use semicolons:  python -c "a = 1; print(a)"   If your code is 
too long for that, it sounds horrible to put it in the command line...

--Ned.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: python -c commands on windows. Ned Batchelder <ned@nedbatchelder.com> - 2013-10-21 17:56 -0400

csiph-web