Py3K idea: why not drop the colon?
Michael Hobbs
mike at hobbshouse.org
Thu Nov 9 11:41:58 EST 2006
Paul Boddie wrote:
> Michael Hobbs wrote:
>
>> I think the colon could be omitted from every type of compound
>> statement: 'if', 'for', 'def', 'class', whatever. Am I missing anything?
>>
>
> The FAQ answer. ;-)
>
> http://www.python.org/doc/faq/general/#why-are-colons-required-for-the-if-while-def-class-statements
>
> Paul
>
I knew there was a document somewhere that I missed. ;-) I even scanned
all the Py3K PEPs before posting. Anyway, the FAQ answer seems to be a
weak argument to me. But if the BDFL insists that it remains, why not
take the converse approach? That is, assume that the expression ends at
the colon, not at the newline. That would make this type of statement
possible:
if color == red or
color == blue or
color == green:
return 'primary'
Right now, such a statement would have to be spelled thus:
if color == red or \
color == blue or \
color == green:
return 'primary'
or
if (color == red or
color == blue or
color == green):
return 'primary'
More information about the Python-list
mailing list