Is there a reason for it?

Example of style50 suggestions, here the '\n' parts should be added, according to it:

# compares lines
def lines(a, b):

To me personally this looks awful but maybe I'm missing something? Especially since I didn't see David (edit: I was proven wrong, that was a false accusation) add this empty space during lectures.

1 Answer 1


PEP 8 is pretty clear on that. https://www.python.org/dev/peps/pep-0008/#blank-lines

Blank Lines

Surround top-level function and class definitions with two blank lines.


Do you have an example of where David did that? I found a few examples where he left only one line empty, but none where the function is preceded by a comment. Probably he did not have to submit the code, so he would not run style50, and maybe he intentionally condensed it to better fit the screen (when showing your screen in a video, you have to choose a bigger font, space becomes more valuable), or that comment relates to the function so he did not want to separate them. Usually one would put a triple-quote type comment at the beginning of a function, interpreted as a "docstring" (as described in PEP 257), but not next to it.

  • First of all, thanks! Yup, you are correct, I searched through all the code and the video - I think I mixed up the descriptive comments of functions with comments within functions which do not need these two lines. Edit the question. Sorry, mea culpa. Would that be considered a discussion though? I mean, I get the two lines for dividing functions, but the comment describing the function is a part of that function logically (to me) so those two lines should precede the comment and not stand between the comment and the function itself.
    – Talim
    Commented Nov 30, 2019 at 19:07
  • Unlike for example C and Java, in Python a function definition is a regular instruction, can appear anywhere in the code. The only way to place a comment describing a function in a way that it is clear what it refers to would be inside the function, exactly where the docstring goes.
    – Blauelf
    Commented Nov 30, 2019 at 23:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .