Wie behebt man "falsche hängende Einkerbung" von Pylint und PEP8 E121?

Ich versuche, richtig Gedankenstrich folgende Stück code:

RULES_LIST = [
    ('Name1', 1, 'Long string upto 40 chars'),
    ('Name2', 2, 'Long string upto 40 chars'),
    ('Name3', 3, 'Long string upto 40 chars'),
    ('Name4', 4, 'Long string upto 40 chars'),
    ('Name5', 5, 'Long string upto 40 chars'),
    ('Name6', 6, 'Long string upto 40 chars'),
    ('Name7', 7, 'Long string upto 40 chars'),
    ('Name8', 8, 'Long string upto 40 chars')
]

Pylint klagt Wrong hanging indentation. für obigen code, und PEP8 klagt E121: under-indented for hanging indent.

Einen möglichen fix für pylint ist es zu verändern:

RULES_LIST = [\
    ('Name1', 1, 'Long string upto 40 chars'),
     ...
    ('Name8', 8, 'Long string upto 40 chars')]

aber PEP8 klagt E121 and E502

PEP8: 1.5.7 (Standard-Konfiguration)
Pylint: 1.3.0 (Standard-Konfiguration)
Python: 2.7.5 (Läuft auf OSX 10.9.3)

Kann die Liste länger werden. Kann jemand bitte empfehlen eine richtige Einbuchtung für das?

InformationsquelleAutor der Frage Jatin Kumar | 2014-08-14

Schreibe einen Kommentar