PEP 8 and extraneous whitespace

A

Andrew Berg

-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

I found a couple things that I think should be tweaked in PEP 8. I don't
agree with everything in PEP 8, but I'm not going to debate /those/
points; rather I'm bringing up a couple examples that violate PEP 8, but
don't apply to the reasons given for their violation. In PEP 8, it says
to avoid extraneous whitespace. For example, this is bad (example taken
from PEP 8):
if x == 4 : print x , y ; x , y = y , x
No need for the extra spaces. But, it makes sense to have extra
whitespace when aligning items in say, a dictionary assignment:
categories = {
'main' : Category(),
'input' : Category(),
'avs' : Category(),
'ffmpeg' : Category(),
'video' : Category(),
'audio' : Category(),
'x264' : Category()
}

PEP8 makes no mention of dictionary assignments, which leads me to think
this was an oversight.

Another example, this time with commas:
self.x264_cmd = (
self.x264_exe, self.avs_file,
'--fps', self.fpsr,
'--sar', self.sar,
'--crf', self.crf,
'--level', self.level,
'--keyint', self.ki,
'--min-keyint', self.minki,
'--ref', self.ref,
'--weightp', self.weightp,
'--bframes', self.bframes,
'--b-adapt', self.badapt,
'--me', self.me,
'--merange', self.merange,
'--direct', self.direct,
'--trellis', self.trellis,
'--subme', self.subme,
'--deblock', self.deblock,
'--output', self.video_output
)
Looks nice all lined up, but it violates PEP 8 because of those extra
spaces, which is only because extra spaces look bad in one-line
assignments that have nothing to do with lists/tuples or dictionaries.
This is one of those times not to follow PEP 8 to the letter, but it
does trip up checker programs (which are useful for catching silly
things like an extra space at the end of a line or missing spaces around
operators). Thoughts?

- --
CPython 3.2.1 | Windows NT 6.1.7601.17592 | Thunderbird 5.0
PGP/GPG Public Key ID: 0xF88E034060A78FCB
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAwAGBQJOKGcEAAoJEPiOA0Bgp4/LNMUH/AgHv4tPn24jDd2pvaessK0U
DkTS3PSWIwKHmlelzYrFxkhS46TDmCrczlx7W+lWkl6vtS74efu+ENrrUUAo+IfL
nEo9IqcS4E6vtiEvBL6Wxbw246NwVJdEUWKme/axYzEsma9wApnGnn0NiXEc8+bL
ufR/HGxIxkRMXPwCv6B6wm+HRvdLsuwq5L+ajpn74hc2NlmCjlDzRBRiccb8kamI
wKeRR6Eq9GoJHVqHS5IyBeik8Zx6L117wX7Id0SCjik9JXVdY4rN6GSRfQlW8Yq5
qw9CKHH3MgYUCw/u0JrBajDRGnXod9WRq12M4tzllqAKIWLWW7yNDQvPfChe2ss=
=yBf+
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,701
Latest member
XavierQ83

Latest Threads

Top