[Tutor] Named function in a single line

Manprit Singh manpritsinghece at gmail.com
Thu Sep 10 13:34:55 EDT 2020


Dear sir ,

I have seen at so many places that smaller named functions are written in a
single line . For example ;

def multiply(a, b):     # a function definition for multiplication of 2
numbers
    return a * b

The function definitions which are very small , normally which contain
only  a single line statement, like that one given above ,  are being found
written in a single line  at so many places . If I write the function given
above in a single line , it would be written like this :

def multiply(a, b) : return a * b

PEP 8 allows us to write such small functions in a single line ?

Regards
Manprit Singh


More information about the Tutor mailing list