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


Groups > comp.lang.python > #79318

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

References (4 earlier) <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>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2014-10-20 11:54 -0600
Subject Re: Is there an easy way to control indents in Python
Newsgroups comp.lang.python
Message-ID <mailman.14998.1413827716.18130.python-list@python.org> (permalink)

Show all headers | View raw


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.

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