PEP 8 : Maximum line Length :
Peter Otten
__peter__ at web.de
Tue May 13 04:45:49 EDT 2014
Ganesh Pal 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)
>
>
> Iam running pylint and it says the above line is tool long how do I limit
> it to 79 character without violating any rules
>
> ************* Module isi_corrupt
> C: 14,0: Line too long (88/80)
> W: 19,0: Bad indentation. Found 6 spaces, expected 8
(1) Newlines are allowed inside an open (, [, or {. So:
p = subprocess.Popen(
shlex.split(cmd),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
Other techniques:
(2) Introduce helper variables:
cmd = shlex.split(cmd)
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(3) Import names:
from subprocess import PIPE
p = subprocess.Popen(shlex.split(cmd), stdout=PIPE, stderr=PIPE)
(4) Use aliases:
import subprocess as sp
p = sp.Popen(shlex.split(cmd), stdout=sp.PIPE, stderr=sp.PIPE)
More information about the Python-list
mailing list