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


Groups > comp.lang.python > #57212

Re: python -c commands on windows.

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <nedbat@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.013
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'continuation': 0.07; 'statements': 0.09; 'python': 0.11; 'windows': 0.15; '(same': 0.16; 'command.': 0.16; 'reedy': 0.16; 'separated': 0.16; 'syntaxerror:': 0.16; 'unexpected': 0.16; 'subject:python': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'module': 0.19; 'command': 0.22; 'manual': 0.22; 'header:User-Agent:1': 0.23; 'header:In-Reply-To:1': 0.27; 'to:2**1': 0.27; 'character': 0.29; 'code': 0.31; '"",': 0.31; 'file': 0.32; 'says': 0.33; 'could': 0.34; 'received:google.com': 0.35; 'too': 0.37; 'work?': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'that,': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'remove': 0.60; 'more': 0.64; 'prompt': 0.68; 'horrible': 0.84; 'subject:commands': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=4gvF+UC6zUAvcBVohBzQ977J5WlhK225jvUplvhbOkk=; b=rkPdBAnlfJGwXP8ZU1SnyojUXbPTS6sl1gGKax9Jglub1563mN3qJIsD4H1bAPhaAg 4pfkeKDU4x31napd+AC1bYzQZIMSYPxd8pm6S6ZGuPsEXxo0mtCU911osXQ9z2Ce06t5 zVSP0DyEQGNwOClEpA46kI/XIh7Z6d6uFgiDaimC7KHpkE5aOyMktpbKZ7NJAyzmbLuw xuRdMHd2PWipHXtkwrT3EqSFH+re36bmhDteK8qowl21yRtv+IxT3Gp3PbFPMGnfWCNI O6XqciMiYw6ECQMXfFr2CFXTq9umRj/3gsYJgKyYI+OdmJ0c0rlW7UfOmKcVgaREYDqH pu5g==
X-Received by 10.229.30.7 with SMTP id s7mr25353095qcc.7.1382392596798; Mon, 21 Oct 2013 14:56:36 -0700 (PDT)
Sender Ned Batchelder <nedbat@gmail.com>
Date Mon, 21 Oct 2013 17:56:35 -0400
From Ned Batchelder <ned@nedbatchelder.com>
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.0.1
MIME-Version 1.0
To Terry Reedy <tjreedy@udel.edu>, python-list@python.org
Subject Re: python -c commands on windows.
References <l443sd$er5$1@ger.gmane.org>
In-Reply-To <l443sd$er5$1@ger.gmane.org>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1326.1382392599.18130.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1382392599 news.xs4all.nl 15931 [2001:888:2000:d::a6]:39926
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:57212

Show key headers only | 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