PEP 8 : Maximum line Length :

Tim Chase python.list at tim.thechases.com
Tue May 13 08:52:06 EDT 2014


On 2014-05-13 22:26, Ben Finney wrote:
> Changing the name on the first line doesn't entail changing any
> other line::
> 
>     proc = Subprocess.Popen(
>             shlex.split(cmd),
>             stdout=subprocess.PIPE,
>             stderr=subprocess.PIPE)
> 
>     special_process_map[this_process] = Subprocess.Popen(
>             shlex.split(cmd),
>             stdout=subprocess.PIPE,
>             stderr=subprocess.PIPE)

I second the idea of just putting each-of-many-parameters on its own
line.  Not only that, I also like to tack on trailing commas and put
the closing paren on its own line to make diffs easier to read:

    special_process_map[this_process] = Subprocess.Popen(
        shlex.split(cmd),
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        )

so that when I add the inevitable parameter, the diff merely reads
like

  --- tim1.txt    2014-05-13 07:44:42.441754319 -0500
  +++ tim2.txt    2014-05-13 07:45:35.753755858 -0500
  @@ -2,4 +2,5 @@
           shlex.split(cmd),
           stdout=subprocess.PIPE,
           stderr=subprocess.PIPE,
  +        bufsize=1024,
          )

which is quite clear that just one line was added, compared to

  --- ben1.txt    2014-05-13 07:44:51.033754566 -0500
  +++ ben2.txt    2014-05-13 07:45:46.737756176 -0500
  @@ -1,4 +1,5 @@
       special_process_map[this_process] = Subprocess.Popen(
           shlex.split(cmd),
           stdout=subprocess.PIPE,
  -        stderr=subprocess.PIPE)
  +        stderr=subprocess.PIPE,
  +        bufsize=1024)

which makes me have to think/verify about whether anything else
changed between insertion and deletion of lines.

-tkc








More information about the Python-list mailing list