Py3K idea: why not drop the colon?

Ben Finney bignose+hates-spam at benfinney.id.au
Thu Nov 9 18:56:04 EST 2006


Please don't hide your new thread as a reply to an existing, unrelated
message. Start a new message if your message isn't actually a reply.

Michael Hobbs <mike at hobbshouse.org> writes:

> Can anyone find a flaw with this change in syntax?
>
> Instead of dividing a compound statement with a colon, why not
> divide it on a newline? For example, the colon could be dropped from
> this statement:
>     if self.hungry:
>         self.eat()
> to
>     if self.hungry
>         self.eat()

But it can't be dropped from this statement:

    if self.hungry: self.eat()

> The colon that divides the statement therefore seems redundant. The
> colon could continue to be used for single-line statements:
>     if self.hungry: self.eat()

Why have two different syntaxes for the same statement?

> I think the colon could be omitted from every type of compound
> statement: 'if', 'for', 'def', 'class', whatever. Am I missing
> anything?

A use case. What problem is being solved by introducing this
inconsistency?

-- 
 \                  "The shortest distance between two points is under |
  `\                                   construction."  -- Noelie Alito |
_o__)                                                                  |
Ben Finney




More information about the Python-list mailing list