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


Groups > comp.lang.python > #79319

Re: Is there an easy way to control indents in Python

Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.011
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'python.': 0.02; 'else:': 0.03; 'subject:Python': 0.06; 'perl,': 0.07; 'line:': 0.09; 'spaces': 0.09; 'python': 0.11; 'def': 0.12; 'attempted': 0.16; 'perl.': 0.16; 'rather,': 0.16; 'set()': 0.16; 'spotted': 0.16; 'thread,': 0.16; 'weight,': 0.16; 'language': 0.16; 'wrote:': 0.18; 'all,': 0.19; "python's": 0.19; 'example': 0.22; 'programming': 0.22; 'rules': 0.22; 'saying': 0.22; 'aspect': 0.24; 'mon,': 0.24; "i've": 0.25; 'least': 0.26; 'header:In-Reply- To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'raise': 0.29; 'start,': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'lines': 0.31; "skip:' 10": 0.31; 'towards': 0.31; 'indentation': 0.31; 'perl': 0.31; 'run': 0.32; 'bugs': 0.33; 'comment': 0.34; 'maybe': 0.34; 'message.': 0.35; 'beyond': 0.35; 'point.': 0.35; 'test': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; "didn't": 0.36; 'should': 0.36; 'too': 0.37; 'two': 0.37; 'step': 0.37; 'to:addr:python-list': 0.38; 'aspects': 0.39; 'weight': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'even': 0.60; 'above,': 0.60; 'blank': 0.60; 'ian': 0.60; 'removing': 0.60; 'new': 0.61; 'refer': 0.63; 'more': 0.64; 'taking': 0.65; 'talking': 0.65; '20,': 0.68; 'line,': 0.68; 'subject:there': 0.68; 'caused': 0.69; 'to,': 0.72; 'cost,': 0.84; 'draws': 0.84; 'kennedy': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=DaR/5BzgSvuQWhxFk2onzXykycjS1Pn5YDbF9uDFq/4=; b=PaZeMNyBFqjyXJTR3FNhyE3Pb0HMbfohBqbnBq+NIeM14Bm/O7j2WTkEdSTMcn1RRJ bMtPD+2EKpx8ohInto4uf5UeoUUIZRUPNwmx2+h+FAAOQScGd9wlvBojwG6CCDjEezWf sPntDplci14GalNmFjOYvQE5vzwOBmjDxhP59iXa6t9kecPQJGkU/o4bebvOgzVwLgld d+r7DkWMYxmwWGVXo7A0yxRxtswjZrVqznEkMhGuDFboESAyItvZPN/+rtOkpAtKUylB afIBwckJHiGakJ61d0TJv0iHlfjpAtDcolkb9ir5OEhN6vavkLgCxH9SfXOfWyQV0HoU UM9w==
X-Received by 10.68.175.196 with SMTP id cc4mr4441892pbc.147.1413827904794; Mon, 20 Oct 2014 10:58:24 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <CALwzid=oS6H-ETtTPsRPawas-Gkj=7hkTWcwLmE8vZ7NdR5R+g@mail.gmail.com>
References <9a0c67be-de3a-4770-bf06-e158783bfff0@googlegroups.com> <mailman.14869.1413339808.18130.python-list@python.org> <m1l7l8$sce$1@dont-email.me> <CAMw+j7+CisEW8=jyVyxkj_7FDj_Lmj+CjjNbJ3Coi2c2q3C2Gg@mail.gmail.com> <m1m9ut$v8f$1@ger.gmane.org> <mailman.14893.1413401464.18130.python-list@python.org> <b474caf0-d910-4f59-86d8-006d316e858b@googlegroups.com> <54424691$0$12978$c3e8da3$5496439d@news.astraweb.com> <bd24df51-bdee-4ccc-82f7-28bf6dbd8bf5@googlegroups.com> <CALwzid=oS6H-ETtTPsRPawas-Gkj=7hkTWcwLmE8vZ7NdR5R+g@mail.gmail.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Mon, 20 Oct 2014 11:57:44 -0600
Subject Re: Is there an easy way to control indents in Python
To Python <python-list@python.org>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
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.14999.1413827908.18130.python-list@python.org> (permalink)
Lines 53
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1413827908 news.xs4all.nl 2932 [2001:888:2000:d::a6]:47510
X-Complaints-To abuse@xs4all.nl
Path csiph.com!usenet.pasdenom.info!bete-des-vosges.org!feed.ac-versailles.fr!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Xref csiph.com comp.lang.python:79319

Show key headers only | View raw


On Mon, Oct 20, 2014 at 11:54 AM, Ian Kelly <ian.g.kelly@gmail.com> wrote:
> On Mon, Oct 20, 2014 at 9:54 AM, Simon Kennedy <sffjunkie@gmail.com> wrote:
>> Not having ever attempted to go beyond even the basics of Perl, the aspect that causes me to refer to Perl 'dismissively' as well comment in this thread, is that I don't find Perl to be an aesthetically pleasing language and I consider Python functions which have no blank lines in them to be a small step towards Perl.
>>
>> Some people do not like Python's indentation rules but for me it's a large part of what draws me to program in Python. Spaces for indentation and blank lines are both aspects of how I like to program.
>>
>> I write in Python because I like to, not because I have to.
>>
>> I think the only reason I might code a function with no blank lines was if I was programming in a language that using blank lines caused it to run too slowly.
>
> So to be clear, I'm not talking about taking a function like this
> (contrived) example and just removing the blank line:
>
> def find_path(graphdata, start, end):
>     edges = map(str.split, lines)
>     graph = collections.defaultdict(list)
>     for node1, node2, weight in edges:
>         graph[node1].append((node[2], int(weight)))
>         graph[node2].append((node[1], int(weight)))
>
>     open_heap = [(0, (start,))]
>     closed_set = set()
>     while open_heap:
>         cost, path = heapq.heappop(open_heap)
>         current_node = path[-1]
>         if current_node == end:
>             return path
>         if current_node in closed_set:
>             continue
>         for next_node, weight in graph[current_node]:
>             heapq.heappush((cost + weight, path + (next_node,)))
>         closed_set.add(current_node)
>     else:
>         raise ValueError("No path from start to end")
>
> Rather, I'm saying that where the blank line is should be the start of
> a new function. There would still be a blank line, just no longer
> inside the function.
>
> Now, maybe you think there should be more blank lines in the above, in
> which case we'll just have to disagree on that point.

By the way, I didn't test that at all, which is why I've spotted at
least two bugs in it since sending the message.

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


Thread

Is there an easy way to control indents in Python ryguy7272 <ryanshuell@gmail.com> - 2014-10-14 19:13 -0700
  Re: Is there an easy way to control indents in Python Juan Christian <juan0christian@gmail.com> - 2014-10-14 23:23 -0300
    Re: Is there an easy way to control indents in Python alex23 <wuwei23@gmail.com> - 2014-10-15 17:27 +1000
      Re: Is there an easy way to control indents in Python Chris “Kwpolska” Warrick <kwpolska@gmail.com> - 2014-10-15 16:32 +0200
        Re: Is there an easy way to control indents in Python alex23 <wuwei23@gmail.com> - 2014-10-16 09:51 +1000
          Re: Is there an easy way to control indents in Python Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-10-17 18:22 +1300
      Re: Is there an easy way to control indents in Python Terry Reedy <tjreedy@udel.edu> - 2014-10-15 13:12 -0400
      Re: Is there an easy way to control indents in Python Ian Kelly <ian.g.kelly@gmail.com> - 2014-10-15 13:30 -0600
        Re: Is there an easy way to control indents in Python Simon Kennedy <sffjunkie@gmail.com> - 2014-10-16 07:08 -0700
          Re: Is there an easy way to control indents in Python Chris Angelico <rosuav@gmail.com> - 2014-10-17 02:02 +1100
          Re: Is there an easy way to control indents in Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-10-18 21:53 +1100
            Re: Is there an easy way to control indents in Python Simon Kennedy <sffjunkie@gmail.com> - 2014-10-20 08:54 -0700
              Re: Is there an easy way to control indents in Python Ian Kelly <ian.g.kelly@gmail.com> - 2014-10-20 11:54 -0600
                Re: Is there an easy way to control indents in Python Simon Kennedy <sffjunkie@gmail.com> - 2014-10-21 01:45 -0700
                Re: Is there an easy way to control indents in Python Ian Kelly <ian.g.kelly@gmail.com> - 2014-10-21 11:09 -0600
              Re: Is there an easy way to control indents in Python Ian Kelly <ian.g.kelly@gmail.com> - 2014-10-20 11:57 -0600
              Re: Is there an easy way to control indents in Python Juan Christian <juan0christian@gmail.com> - 2014-10-20 17:04 -0200
              Re: Is there an easy way to control indents in Python Ian Kelly <ian.g.kelly@gmail.com> - 2014-10-20 13:40 -0600
              Re: Is there an easy way to control indents in Python MRAB <python@mrabarnett.plus.com> - 2014-10-20 20:43 +0100
              Re: Is there an easy way to control indents in Python Juan Christian <juan0christian@gmail.com> - 2014-10-20 20:30 -0200
              Re: Is there an easy way to control indents in Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-10-20 21:13 -0400
  Re: Is there an easy way to control indents in Python Chris Angelico <rosuav@gmail.com> - 2014-10-15 13:18 +1100
  Re: Is there an easy way to control indents in Python Dan Stromberg <drsalists@gmail.com> - 2014-10-14 19:38 -0700
  Re: Is there an easy way to control indents in Python Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-10-14 21:35 -0500
  Re: Is there an easy way to control indents in Python Chris Angelico <rosuav@gmail.com> - 2014-10-15 13:47 +1100
  Re: Is there an easy way to control indents in Python jumppanen.jussi@gmail.com - 2014-10-21 06:51 -0700

csiph-web