PEP 8 : Maximum line Length :

Roy Smith roy at panix.com
Tue May 13 08:09:37 EDT 2014


In article <mailman.9945.1399965443.18130.python-list at python.org>,
 Ganesh Pal <ganesh1pal at gmail.com> wrote:

> Hi  Team ,
> 
> 
> what would be the best way to intent the below line .
> 
> I have few lines in my program exceeding the allowed maximum line Length of
> 79./80 characters
> 
> Example 1 :
> 
>    p = Subprocess.Popen(shlex.split(cmd),stdout=subprocess.PIPE,stderr=subprocess.PIPE)

The problem here is not so much that you've exceeded 80 columns, but that there's no logical
structure which gives your eyes (and your brain) hints about how to parse this.  I would
start by adding some white space

>    p = Subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE, stderr=subprocess.PIPE)

now, at least, it's easier to see where each argument stops and the next one starts.  But,
I would really break this up into multiple lines

>    p = Subprocess.Popen(shlex.split(cmd),
>                         stdout=subprocess.PIPE,
>                         stderr=subprocess.PIPE)



More information about the Python-list mailing list