Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #73982
| Date | 2014-07-04 18:35 -0500 |
|---|---|
| From | Tim Chase <python.list@tim.thechases.com> |
| Subject | Re: PEP8 and 4 spaces |
| References | (2 earlier) <mailman.11466.1404410853.18130.python-list@python.org> <53b6019f$0$29985$c3e8da3$5496439d@news.astraweb.com> <c1n1fbFi6omU1@mid.individual.net> <mailman.11507.1404498596.18130.python-list@python.org> <c1oqvpFtsj1U2@mid.individual.net> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.11513.1404517000.18130.python-list@python.org> (permalink) |
On 2014-07-05 11:17, Gregory Ewing wrote:
> > PEP8 suggests using this style of method invocation:
> >
> > obj.method(foo,
> > bar,
> > baz)
> >
> > which is an effect impossible to do correctly with tabs alone.
>
> Yes, PEP 8 is self-contradictory in that regard.
> I also happen to think that recommendation is insane
> for other reasons as well, and cheerfully ignore it.
To be fair, in the same section[1] that example is given, it also
suggests
# More indentation included to distinguish this from the rest.
def long_function_name(
var_one, var_two, var_three,
var_four):
print(var_one)
# Hanging indents should add a level.
foo = long_function_name(
var_one, var_two,
var_three, var_four)
both of which can be done with arbitrary indentation without the need
to mix tabs+spaces or use a non-integer multiple of
indentation-spaces. I just use these two in all instances and (as
you, Greg, advise), "cheerfully ignore [the first form]"
The only time I intentionally violate the "don't do these" section
"""
# Arguments on first line forbidden when not using vertical alignment.
foo = long_function_name(var_one, var_two,
var_three, var_four)
"""
is when defining options in optparse:
parser.add_option("-v", "--verbose",
help="be prolix",
action="store_true",
dest="verbose",
default=False,
)
as I find that a little easier to read when I'm scanning large blocks
of parser.add_option(...) calls, having the option stick out to the
right.
-tkc
[1] http://legacy.python.org/dev/peps/pep-0008/#indentation
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: PEP8 and 4 spaces Paul Sokolovsky <pmiscml@gmail.com> - 2014-07-03 21:07 +0300
Re: PEP8 and 4 spaces wxjmfauth@gmail.com - 2014-07-03 12:22 -0700
Re: PEP8 and 4 spaces Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-07-04 01:21 +0000
Re: PEP8 and 4 spaces Chris Angelico <rosuav@gmail.com> - 2014-07-04 11:30 +1000
Re: PEP8 and 4 spaces Roy Smith <roy@panix.com> - 2014-07-03 21:37 -0400
Re: PEP8 and 4 spaces Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-07-04 18:55 +1200
Re: PEP8 and 4 spaces Lie Ryan <lie.1296@gmail.com> - 2014-07-04 19:29 +0100
Re: PEP8 and 4 spaces Roy Smith <roy@panix.com> - 2014-07-04 15:04 -0400
Re: PEP8 and 4 spaces Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-07-04 20:50 +0100
Re: PEP8 and 4 spaces Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-07-05 11:17 +1200
Re: PEP8 and 4 spaces Tim Chase <python.list@tim.thechases.com> - 2014-07-04 18:35 -0500
Re: PEP8 and 4 spaces Travis Griggs <travisgriggs@gmail.com> - 2014-07-05 00:51 -0700
csiph-web