Py3K idea: why not drop the colon?

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Thu Nov 9 17:32:27 CET 2006


In <mailman.1983.1163089419.11739.python-list at python.org>, Michael Hobbs
wrote:

> Python is already sensitive to whitespace and the newline anyway, so why 
> not put it to good use? For example, Python rejects this statement 
> because of the newline present:
>     if self.hungry or
>       self.depressed:
>         self.eat()
> You need to use the backslash to continue the expression on the next line:
>     if self.hungry or \
>       self.depressed:
>         self.eat()

You don't need the backslash if you use parenthesis:

  if (self.hungry
      or self.depressed):
      self.eat()

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

I would miss auto-indenting in my editor to which the colon at the line
end is an important clue.

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list