Tino Dai wrote: > Hi! > > I have a question about style. In PEP-8, it says don't exceed 79 > characters, but can this rule ever be trumped by > readability? > > Eg. > > > if someobject.filter(something) \ > .filter(somethingreallyreallyreallyreallylong == > somethingelsereallyreallylong) \ > .filter(othethingreallylongreallyreally == > ternarythingreallyreallyreallylong) \ > .filter(thirdthingreallylessreallymaybelong == > thirdotherthingreallylong) \ > .first(): > < do something > > > if someobject.filter(something) \ > .filter(somethingreallyreallyreallyreallylong == \ > somethingelsereallyreallylong) \ > .filter(othethingreallylongreallyreally == \ > ternarythingreallyreallyreallylong ) \ > .filter(thirdthingreallylessreallymaybelong == \ > thirdotherthingreallylong) \ > .first(): > < do something > > > > The first example is more readable to me but violates the 80 character > rule. The second is less readable, but doesn't violate > the 80 character rule. > > Is there a guideline or convention that pythonistas follow about this > style case?
I would give you a thoughtful answer, but I am currently facing a serious problem myself: my stretch limo doesn't fit into my garage. Should I drive through the back wall or block the street with the part that sticks out? Seriously, learn that you don't need backslashes if you put the expression into parens, precalculate parts of the expression and put them into temporary variables -- and if that doesn't suffice to keep the code readable and below the 80 char threshold reread the part of the PEP with the Emerson quote ("A foolish consistency..."). _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor