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


Groups > comp.lang.python > #53233

Re: semicolon at end of python's statements

Path csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!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.013
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'python,': 0.02; 'iterate': 0.09; 'mixed': 0.09; 'val': 0.09; 'python': 0.11; 'language,': 0.12; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'indent': 0.16; 'iterates': 0.16; 'syntactic': 0.16; 'subject:python': 0.16; 'flexibility': 0.16; 'language': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'example': 0.22; 'aug': 0.22; 'instance,': 0.24; 'looks': 0.24; 'sort': 0.25; 'required.': 0.27; 'header:In-Reply-To:1': 0.27; "doesn't": 0.30; 'matching': 0.30; 'message-id:@mail.gmail.com': 0.30; '(which': 0.31; 'code': 0.31; 'indentation': 0.31; 'subject:end': 0.31; 'probably': 0.32; 'cases': 0.33; 'level.': 0.33; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'version': 0.36; 'doubt': 0.36; 'done': 0.36; 'should': 0.36; 'two': 0.37; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'structure': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'even': 0.60; 'expression': 0.60; 'most': 0.60; 'simply': 0.61; 'levels': 0.65; 'reads': 0.68; 'physical': 0.72; 'filtered': 0.84; 'technically': 0.84; '2013': 0.98
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=AqHYhw3uUdHqLzMVE+PJeA3D8APB21nCkqmqF6iQ6sA=; b=ND5dygJyBtP0PRNzmTAQvxeyCcy0I7AeHOIILxmUjHTVkszQE3f6WNBhG90QfXVK4a 9hO3o5GN9nq0pqRezaj4/1pA1wrGSZGfGqk/1yqfCCfE36XKJqYFglZMca57OME0hrIh KLW4uQfmoeBXNlXIU9YA48ASZTWwEUfRxZ2uXwQ9ydStnNwZWLTG642ipjtNC/Q/e7g6 YDW7cyY6D/1CCjXeb+PYA6wbAYGpVnQx/1cCa0RxOabPvyYfDXR4aWOHuDRxoUIJWIev i3kvDYOjDnBKQL/pPM2dMkaKzrv63yYPqRL8H2DJlpyUf6vE5rG5BJQR5shBLjaGEH8G PCAg==
MIME-Version 1.0
X-Received by 10.58.246.8 with SMTP id xs8mr2394543vec.9.1377769939313; Thu, 29 Aug 2013 02:52:19 -0700 (PDT)
In-Reply-To <1FETt.52607$Mw4.14965@fx15.am4>
References <1377735506.18906.15.camel@debian> <mailman.347.1377760274.19984.python-list@python.org> <1FETt.52607$Mw4.14965@fx15.am4>
Date Thu, 29 Aug 2013 19:52:19 +1000
Subject Re: semicolon at end of python's statements
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.354.1377769942.19984.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1377769942 news.xs4all.nl 15886 [2001:888:2000:d::a6]:48717
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:53233

Show key headers only | View raw


On Thu, Aug 29, 2013 at 7:39 PM, Alister <alister.ware@ntlworld.com> wrote:
> Yet no doubt you voluntarily indent your c code to make it readable?
> it wont take long before you find you don't even think about indentation
> and actually like it

Most of the time, in any language, I will indeed have indentation
matching the syntactic structure of the code (which is what Python
demands). But I like the flexibility of having the indentation under
_my_ control, not under the language's, because my rule is that it
should match the *logical*, not syntactic, structure. For instance,
here's how code looks that iterates over an array:

foreach (some_array, mixed val)
{
    //do something with val
}

And here's how it looks if I want to iterate over a filtered version
of the array:

foreach (some_array, mixed val) if (some_condition)
{
    //do something with val
}

There's no language support required. It reads like a Python
list-comp, simply adding a condition as part of the loop header. But
it technically breaks the indentation rules, and Python doesn't allow
this sort of thing. In Python, this particular example is probably
best done with a generator expression in the for loop, but there are
other cases where I combine two physical structural levels into a
single line and indent level.

ChrisA

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


Thread

Re: semicolon at end of python's statements "Sam Fourman Jr." <sfourman@gmail.com> - 2013-08-28 22:10 -0400
  Re: semicolon at end of python's statements Alister <alister.ware@ntlworld.com> - 2013-08-29 09:39 +0000
    Re: semicolon at end of python's statements Chris Angelico <rosuav@gmail.com> - 2013-08-29 19:52 +1000
    Re: semicolon at end of python's statements Fábio Santos <fabiosantosart@gmail.com> - 2013-08-29 11:02 +0100
    Re: semicolon at end of python's statements Ben Finney <ben+python@benfinney.id.au> - 2013-08-30 08:17 +1000
    Re: semicolon at end of python's statements Chris Angelico <rosuav@gmail.com> - 2013-08-30 08:50 +1000
    Re: semicolon at end of python's statements Ben Finney <ben+python@benfinney.id.au> - 2013-08-30 14:55 +1000
    Re: semicolon at end of python's statements Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-08-30 09:15 +0200
    Re: semicolon at end of python's statements Chris Angelico <rosuav@gmail.com> - 2013-08-30 17:25 +1000
    Re: semicolon at end of python's statements Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-08-30 09:48 +0200
    Re: semicolon at end of python's statements Fábio Santos <fabiosantosart@gmail.com> - 2013-08-30 11:32 +0100
      Re: semicolon at end of python's statements Roy Smith <roy@panix.com> - 2013-08-30 06:53 -0400
        Re: semicolon at end of python's statements Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-08-30 16:14 +0200
        Re: semicolon at end of python's statements Chris Angelico <rosuav@gmail.com> - 2013-08-31 08:18 +1000
      Re: semicolon at end of python's statements Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-31 00:09 +0000
        Re: semicolon at end of python's statements Terry Reedy <tjreedy@udel.edu> - 2013-08-31 01:03 -0400
        Re: semicolon at end of python's statements Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-08-31 10:47 +0300
          Re: semicolon at end of python's statements Paul Rudin <paul.nospam@rudin.co.uk> - 2013-08-31 09:00 +0100
            Re: semicolon at end of python's statements Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-08-31 13:28 +0300
            Re: semicolon at end of python's statements Grant Edwards <invalid@invalid.invalid> - 2013-09-02 14:20 +0000
              Re: semicolon at end of python's statements Tim Chase <python.list@tim.thechases.com> - 2013-09-02 09:45 -0500
                Re: semicolon at end of python's statements Roy Smith <roy@panix.com> - 2013-09-02 10:47 -0400
                Re: semicolon at end of python's statements Tim Chase <python.list@tim.thechases.com> - 2013-09-02 12:58 -0500
                Re: semicolon at end of python's statements Chris Angelico <rosuav@gmail.com> - 2013-09-03 07:07 +1000
        Re: semicolon at end of python's statements Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-09-01 19:58 +0200
        Re: semicolon at end of python's statements Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-09-01 21:58 +0200
          Re: semicolon at end of python's statements Steven D'Aprano <steve@pearwood.info> - 2013-09-02 08:05 +0000
            Re: semicolon at end of python's statements Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-09-02 11:45 +0200
            Re: semicolon at end of python's statements Fábio Santos <fabiosantosart@gmail.com> - 2013-09-02 11:42 +0100
            Re: semicolon at end of python's statements Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-09-02 12:58 +0200
            Re: semicolon at end of python's statements "albert visser" <albert.visser@gmail.com> - 2013-09-02 19:44 +0200
              Re: semicolon at end of python's statements Roy Smith <roy@panix.com> - 2013-09-02 13:53 -0400
                Re: semicolon at end of python's statements Neil Cerutti <neilc@norwich.edu> - 2013-09-03 17:15 +0000
                Re: semicolon at end of python's statements Neil Cerutti <neilc@norwich.edu> - 2013-09-03 20:00 +0000
            Re: semicolon at end of python's statements Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-09-02 17:24 -0400
        Re: semicolon at end of python's statements MRAB <python@mrabarnett.plus.com> - 2013-09-02 00:30 +0100
        Re: semicolon at end of python's statements Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-09-02 10:29 +0200
          Re: semicolon at end of python's statements Steven D'Aprano <steve@pearwood.info> - 2013-09-02 09:52 +0000
            Re: semicolon at end of python's statements Chris Angelico <rosuav@gmail.com> - 2013-09-02 20:14 +1000
              Re: semicolon at end of python's statements Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-09-02 14:57 +0000
            Re: semicolon at end of python's statements Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-09-02 12:52 +0200
            Re: semicolon at end of python's statements Modulok <modulok@gmail.com> - 2013-09-02 17:17 -0600
              Re: semicolon at end of python's statements Roy Smith <roy@panix.com> - 2013-09-02 19:54 -0400
                Re: semicolon at end of python's statements Modulok <modulok@gmail.com> - 2013-09-02 18:56 -0600

csiph-web