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


Groups > comp.lang.python > #9242

Re: An interesting beginner question: why we need colon at all in the python language?

Date 2011-07-11 16:16 +0200
From Thomas Jollans <t@jollybox.de>
Subject Re: An interesting beginner question: why we need colon at all in the python language?
References <CAAyd8ckM7WqzTpXzVFFocEFQcm8oeHPQGAv1KH6BcBj6kqA2WA@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.889.1310393783.1164.python-list@python.org> (permalink)

Show all headers | View raw


On 07/11/2011 03:51 PM, Anthony Kong wrote:
> Hi, all,
> 
> Lately I am giving some presentations to my colleagues about the python
> language. A new internal project is coming up which will require the use
> of python.
> 
> One of my colleague asked an interesting:
> 
> /If Python use indentation to denote scope, why it still needs
> semi-colon at the end of function declaration and for/while/if loop?/
> 
> My immediate response is: it allows us to fit statements into one line.
> e.g. if a == 1: print a
> 
> However I do not find it to be a particularly strong argument. I think
> PEP8 does not recommend this kind of coding style anyway, so one-liner
> should not be used in the first place!

Basically, it looks better, and is more readable. A colon, in English
like in Python, means that something follows that is related to what was
before the colon. So the colon makes it abundantly clear to the human
reader that a block follows, and that that block is to be considered in
relation to what was just said, before the colon.

Coincidentally, Guido wrote this blog post just last week, without which
I'd be just as much at a loss as you:

http://python-history.blogspot.com/2011/07/karin-dewar-indentation-and-colon.html

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


Thread

Re: An interesting beginner question: why we need colon at all in the python language? Thomas Jollans <t@jollybox.de> - 2011-07-11 16:16 +0200
  Re: An interesting beginner question: why we need colon at all in the python language? Grant Edwards <invalid@invalid.invalid> - 2011-07-11 14:43 +0000
  Re: An interesting beginner question: why we need colon at all in the python language? alex23 <wuwei23@gmail.com> - 2011-07-12 23:26 -0700
    Re: An interesting beginner question: why we need colon at all in the python language? Terry Reedy <tjreedy@udel.edu> - 2011-07-13 12:18 -0400
  Re: An interesting beginner question: why we need colon at all in   the python language? Thorsten Kampe <thorsten@thorstenkampe.de> - 2011-07-13 10:08 +0200
    Re: An interesting beginner question: why we need colon at all in   the python language? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-07-13 21:07 +1000
      Re: An interesting beginner question: why we need colon at all in   the python language? Thorsten Kampe <thorsten@thorstenkampe.de> - 2011-07-13 13:26 +0200
        Re: An interesting beginner question: why we need colon at all in the python language? Tim Chase <python.list@tim.thechases.com> - 2011-07-13 07:16 -0500
      Re: An interesting beginner question: why we need colon at all in the python language? Chris Angelico <rosuav@gmail.com> - 2011-07-13 21:58 +1000
      Re: An interesting beginner question: why we need colon at all in   the python language? Grant Edwards <invalid@invalid.invalid> - 2011-07-13 13:18 +0000
    Re: An interesting beginner question: why we need colon at all in   the python language? Grant Edwards <invalid@invalid.invalid> - 2011-07-13 13:03 +0000
      Re: An interesting beginner question: why we need colon at all in the python language? Chris Angelico <rosuav@gmail.com> - 2011-07-13 23:11 +1000
      Re: An interesting beginner question: why we need colon at all in     the python language? Thorsten Kampe <thorsten@thorstenkampe.de> - 2011-07-13 19:27 +0200
      Re: An interesting beginner question: why we need colon at all in the python language? Grant Edwards <invalid@invalid.invalid> - 2011-07-14 14:34 +0000
        Re: An interesting beginner question: why we need colon at all in the python language? Wanderer <wanderer@dialup4less.com> - 2011-07-14 08:14 -0700
          Re: An interesting beginner question: why we need colon at all in the python language? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-07-16 14:07 +1000

csiph-web