R
R
Refiru2020-08-23 14:09:38
Python
Refiru, 2020-08-23 14:09:38

Pep8 how to wrap a line in this variant?

Good afternoon, how to wrap lines correctly?

# мне кажется так читается лучше
cursor.execute("""CREATE TABLE IF NOT EXISTS Users
(ID INTEGER NOT NULL PRIMARY KEY, Text TEXT, Configuration Text) """)
# в коде часто вижу так
cursor.execute("""CREATE TABLE IF NOT EXISTS Users
                (ID INTEGER NOT NULL PRIMARY KEY,
               Text TEXT, Configuration Text) """)

Both options fit in a line of 79 characters.
But the first one doesn't align with the other options with spaces.
And the second is read worse, IMHO. More precisely, it's easier for me to read the SQL query in the first version, but it seems people are trying to highlight "cursor.execute"?
Is this important for pep8? Or is this the case where you can write in a more convenient way?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2020-08-23
@Refiru

option

cursor.execute(
    'CREATE TABLE IF NOT EXISTS Users('
    'ID INTEGER NOT NULL PRIMARY KEY,'
    'Text TEXT,'
    'Configuration Text)'
)

well, or even brackets can be in separate lines

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question