Parentheses (as after "print")

Chris Angelico rosuav at gmail.com
Tue Sep 26 16:10:21 EDT 2017


On Wed, Sep 27, 2017 at 6:00 AM, Stefan Ram <ram at zedat.fu-berlin.de> wrote:
> ram at zedat.fu-berlin.de (Stefan Ram) writes:
>>Stefan Behnel <stefan_ml at behnel.de> writes:
>>>But would you also write this?
> ...
>>>    def(func(a,b,c)):
>>>        return(a+b+c)
>>No, this not.
>
>   What I wrote was like:
>
> func( a, b, c )
>     return a+b+c
>
>   Python could have taken the indentation of the
>   next line to tell that this is supposed to be
>   a function definition and not a function call.
>
>   I forgot »:« and »def«, and sometimes I forget
>   other things, but I never forgot the proper
>   indentation, never got the indentation wrong
>   so far, not even once.

That's a DWIMmy feature, and those are often *bad* in language design.
But if you can pin down your exact style (as here - you ALWAYS get the
indentation right), you could - in theory, at least - configure your
editor to notice that you left out the "def" and the colon, and add
them for you. Definitely wants to be an editor feature though.

ChrisA



More information about the Python-list mailing list