Guido sees the light: PEP 8 updated
Random832
random832 at fastmail.com
Tue Apr 19 10:05:48 EDT 2016
On Tue, Apr 19, 2016, at 08:55, Rustom Mody wrote:
> > Like, it ends up looking like this:
> >
> > if foo("what if it's a much longer condition"): # comment
> > do something #
> > comment2
> >
> > There's no way to get this:
> >
> > if foo("what if it's a much longer condition"): # comment
> > do something # comment2
>
> I get it looking quite nice if I put a tab between "foo" and "("
> Is that an acceptable solution?? Dunno...
No, because what if "foo" is much longer? You could put a tab after
"if", but that means while-blocks are indented further than if-blocks.
And that just delays the problem to the third indent block, you've got
to find something to line that up to.
if foo("blah blah blah"): # comment
if bar("etc etc etc etc"): # comment
do stuff # comment
becomes
if foo ("blah blah blah"): # comment
if bar ("etc etc etc etc"): # comment
do stuff # comment
Maybe what we really need is a way to _display_ a multiline comment at
the right margin (and hanging down for as many lines as it needs),
without having it baked into the source code that way.
Source file contains:
### Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam
### ut mattis leo. In sed arcu gravida, consequat tellus placerat,
### ullamcorper metus.
if foo:
if bar:
do stuff
###
some other stuff
(the last ### is just an empty comment to push stuff after it down past
the first comment - if another comment is there instead, it will be
displayed starting from the "some other stuff" line)
Displays as:
if foo: # Lorem ipsum dolor sit amet, consectetur
if bar: # adipiscing elit. Etiam ut mattis leo. In sed
do stuff # arcu gravida, consequat tellus
# placerat, ullamcorper metus.
some other stuff
More information about the Python-list
mailing list