Doubts about PEP8 [duplicate]

1

I read the PEP8 but I did not quite understand it when using 2 blanks.

Should I use 2 spaces to separate a section of imports from another section?

What sections does a Python file typically have?

Should I have a file with all my classes or a file for each class as in other languages?

import os
import random
import threading

import pygame

from classes import Carta


def main():
    pass


main()

Is that correct? Two spaces between the imports section and the main function plus 2 between the main function and the call to it?

    
asked by anonymous 01.11.2017 / 13:12

1 answer

2

There are two spaces, two blank lines.

PEP8 does not say anything about separating imports , but I think it only makes sense to separate all of them from the rest of the code, so it would look like this:

import os
import random
import threading
import pygame
from classes import Carta


def main():
    pass


main()

But you can leave a line only after imports . I do not see the same advantage of separating as much as it is from loose classes and functions.

I do not really like this idea of sections. But it is common to have imports, loose functions, classes and even loose code that should be avoided.

    
01.11.2017 / 13:34