Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #31214
| Path | csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'indicating': 0.05; 'level,': 0.07; 'subject:How': 0.09; 'python': 0.09; '"if': 0.09; 'declarations': 0.09; 'prevents': 0.09; 'subject:command': 0.09; 'subject:while': 0.09; 'subject:python': 0.11; 'assume': 0.11; 'language': 0.14; '[it': 0.16; 'fail,': 0.16; 'false:': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'nesting': 0.16; 'oct': 0.16; 'peers.': 0.16; 'semicolon': 0.16; 'shells': 0.16; 'statements,': 0.16; 'true:': 0.16; 'wrote:': 0.17; 'variable': 0.20; 'received:209.85.214.174': 0.21; 'statement': 0.23; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'block,': 0.29; 'changed.': 0.29; 'consequence': 0.29; 'indentation': 0.29; 'to:addr:python-list': 0.33; "can't": 0.34; 'received:google.com': 0.34; 'consistent': 0.35; 'subject:?': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'subject:" ': 0.36; 'method': 0.36; 'uses': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'easily': 0.39; 'header:Received:5': 0.40; 'end': 0.40; 'your': 0.60; 'skip:n 10': 0.63; 'become': 0.65; 'increase': 0.72; 'subject: -': 0.84; 'increases': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=rMncVSTW7/gKn5alkZkaZPHQxqoN9h3w0BokvnEsk/M=; b=G3+ShfXVMylB2VQNgwKv4pU/40zW3CdF/t6MRXu+6CQ4lCR0XWQvN8s59FJyB3hfGl UpDmB+/5SrqVm7O3fRTecm39BfEarzPM4/4e9Tg3Itu+DNTTQj/B8WhbpNk1ZFaxFHQT aslW4yP+Lhq0sizB7n9TSs71p8AzL8ek+Ixds0N7hm7PwfW33ODJxz2uj37dJMuISyZK rP1devKsx35MfvtK8ekWpYrc2Solo5yjM7Q1iQXfqwr4c+KgmKxlU+OtJYJ9ceZNfuru W5dUgafahEEz6cch52CWAOFqhwFjOmtKmjRBMmRmG5B28U7lEo+T+Dd08pk8f74Vnp/+ ay+g== |
| MIME-Version | 1.0 |
| In-Reply-To | <CAN1F8qV5=EDYs66CrTJf=ObRM+O+bb9YOt-Z+oT5H6Ci9Nq1tQ@mail.gmail.com> |
| References | <CANOe_mhhn31Qb2iB1nWydWSm=MJ0xK0o5vxWR+mLeO5ggqwmwQ@mail.gmail.com> <mailman.2101.1350083051.27098.python-list@python.org> <5078b6a9$0$6574$c3e8da3$5496439d@news.astraweb.com> <20121013084132.GA5083@taris.box> <CAPTjJmrBc1hABysXXpkTs3YWnBukEg=WiZD2TFnUWnQmXJ-t7g@mail.gmail.com> <CAN1F8qX50y6uVFXs6OxZaVYyUPT-1jLHqY5GoDr3x4Xctd0Xtw@mail.gmail.com> <CAPTjJmob-ugLjSJ1G7KWYUBNv_Ksu9Ow3xtzKhxsjRzFhpk7VA@mail.gmail.com> <CAN1F8qV5=EDYs66CrTJf=ObRM+O+bb9YOt-Z+oT5H6Ci9Nq1tQ@mail.gmail.com> |
| Date | Sun, 14 Oct 2012 05:41:11 +1100 |
| Subject | Re: How to use "while" within the command in -c option of python? |
| From | Chris Angelico <rosuav@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| 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 | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2133.1350153673.27098.python-list@python.org> (permalink) |
| Lines | 30 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1350153673 news.xs4all.nl 6947 [2001:888:2000:d::a6]:60541 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:31214 |
Show key headers only | View raw
On Sun, Oct 14, 2012 at 5:21 AM, Joshua Landau <joshua.landau.ws@gmail.com> wrote: > Because Python uses indentation, what would "if A: print(1); if B: print(2)" > even do? It has to fail, because we have to assume consistent indentation > for ";"s*. With "\n" as I proposed, you still have to indent: it is just a > method to bypass lame shells [it would become "if A: print(1)\nif B: > print(2)"]. sikorsky@sikorsky:~/cpython$ python -c "if False: print(1); print(2)" sikorsky@sikorsky:~/cpython$ python -c "if True: print(1); print(2)" 1 2 sikorsky@sikorsky:~/cpython$ The semicolon separates statements, but doesn't change nesting levels. The if statement increases the nesting level, which demands a corresponding indentation increase if you go onto a new line; the statement you describe is illegal because the 'if' isn't allowed to not be at the beginning of the line, but it's unambiguous. Of course, since Python lacks a non-whitespace way of indicating the end of an if block, there's no way to put your "if A" and "if B" onto the same line as peers. But that's a consequence of a design decision, and one that can't easily be changed. Every language has warts like that; eschewing variable declarations prevents infinite nesting of scopes, but demanding variable declarations makes interactive work harder. To paraphrase the Pirate King: Always follow the dictates of your conscience, and accept the consequences. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: How to use "while" within the command in -c option of python? Etienne Robillard <animelovin@gmail.com> - 2012-10-12 19:04 -0400
Re: How to use "while" within the command in -c option of python? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-10-13 00:32 +0000
Re: How to use "while" within the command in -c option of python? Thomas Bach <thbach@students.uni-mainz.de> - 2012-10-13 10:41 +0200
Re: How to use "while" within the command in -c option of python? Chris Angelico <rosuav@gmail.com> - 2012-10-13 20:03 +1100
Re: How to use "while" within the command in -c option of python? Chris Angelico <rosuav@gmail.com> - 2012-10-14 04:23 +1100
Re: How to use "while" within the command in -c option of python? Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2012-10-13 20:43 +0300
Re: How to use "while" within the command in -c option of python? Chris Angelico <rosuav@gmail.com> - 2012-10-14 04:47 +1100
Re: How to use "while" within the command in -c option of python? Chris Angelico <rosuav@gmail.com> - 2012-10-14 05:41 +1100
Re: How to use "while" within the command in -c option of python? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-10-13 15:19 -0400
Re: How to use "while" within the command in -c option of python? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-10-13 16:42 -0400
Re: How to use "while" within the command in -c option of python? Chris Angelico <rosuav@gmail.com> - 2012-10-14 08:39 +1100
Re: How to use "while" within the command in -c option of python? Chris Angelico <rosuav@gmail.com> - 2012-10-14 09:09 +1100
csiph-web