2

I believe that the question is not a duplicate as the other question does not respond to the question of readability.

In the contributing guidelines of the library scikit-learn, they refer to a document for coding standards, see here, in which you can find the following remarks:

        # Functions/methods that do not return a value should still be
        # delimited by a return statement.  Please tell me you don't have to
        # ask why!
        return

However, there is no difference in the return value, and I don't see the improvements in readability of the code. I looked for people that detailed this point, but none of them tackled this subject from the angle of readability.

So why is it better to write return everytime ?

Robin Vogel
  • 159
  • 9
  • As someone who started by learning c and c++ code, and isn't super familiar with python yet, seeing the return gives me a sense of security, but I don't think that would be a problem with anyone with a bit more experience. – EnigmaticBacon Mar 31 '19 at 20:37
  • 2
    "Please tell me you don't have to ask why!" This kind of language makes my blood boil. – Harald Nordgren Mar 31 '19 at 20:38
  • 1
    That documentation's a little condescending, eh? – Jeremy Mar 31 '19 at 20:38

1 Answers1

2

In this example they refer to the return statement as a delimiter, hence a visual way to identify the end of a function block.

This is not an official part of PEP and personally I don't think it is necessary as Python has strong enough visual cues with indentation.

Kieran
  • 316
  • 5
  • 15