PEP 8 and extraneous whitespace

Discussion in 'Python' started by Andrew Berg, Jul 21, 2011.

  1. Andrew Berg

    Andrew Berg Guest

    -----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-----
    Andrew Berg, Jul 21, 2011
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?ZGhucml2ZXJzaWRl?=

    extraneous dlls in bin causes failure?

    =?Utf-8?B?ZGhucml2ZXJzaWRl?=, May 17, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    327
    =?Utf-8?B?ZG9uZ3dhbmc=?=
    May 19, 2005
  2. Oli Filth
    Replies:
    9
    Views:
    3,325
    Uncle Pirate
    Jan 17, 2005
  3. Steven Allport
    Replies:
    3
    Views:
    957
    Steven Allport
    Jan 2, 2008
  4. Andrew Berg

    Re: PEP 8 and extraneous whitespace

    Andrew Berg, Jul 21, 2011, in forum: Python
    Replies:
    4
    Views:
    483
    Thomas 'PointedEars' Lahn
    Jul 22, 2011
  5. Terry Reedy

    Re: PEP 8 and extraneous whitespace

    Terry Reedy, Jul 21, 2011, in forum: Python
    Replies:
    31
    Views:
    721
    Thomas 'PointedEars' Lahn
    Aug 1, 2011
Loading...

Share This Page