Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #71452

Re: PEP 8 : Maximum line Length :

From Peter Otten <__peter__@web.de>
Subject Re: PEP 8 : Maximum line Length :
Date 2014-05-13 10:45 +0200
Organization None
References <CACT3xuWxJHqqV26R+3aYvpovRs7OZ6_TFynSVV-n-b+EkMmtKA@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.9952.1399970767.18130.python-list@python.org> (permalink)

Show all headers | View raw


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)

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: PEP 8 : Maximum line Length : Peter Otten <__peter__@web.de> - 2014-05-13 10:45 +0200
  Re: PEP 8 : Maximum line Length : Rustom Mody <rustompmody@gmail.com> - 2014-05-13 06:18 -0700
  Re: PEP 8 : Maximum line Length : wxjmfauth@gmail.com - 2014-05-15 07:17 -0700
    Re: PEP 8 : Maximum line Length : Chris Angelico <rosuav@gmail.com> - 2014-05-16 00:27 +1000
      Re: PEP 8 : Maximum line Length : wxjmfauth@gmail.com - 2014-05-15 08:48 -0700
      Re: PEP 8 : Maximum line Length : albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-05-17 12:52 +0000
        Re: PEP 8 : Maximum line Length : Chris Angelico <rosuav@gmail.com> - 2014-05-17 23:18 +1000
          Re: PEP 8 : Maximum line Length : Roy Smith <roy@panix.com> - 2014-05-17 09:49 -0400
        Re: PEP 8 : Maximum line Length : Tim Chase <python.list@tim.thechases.com> - 2014-05-17 08:28 -0500
          Re: PEP 8 : Maximum line Length : Roy Smith <roy@panix.com> - 2014-05-17 09:46 -0400
        Re: PEP 8 : Maximum line Length : Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-05-17 15:02 +0100
          Re: PEP 8 : Maximum line Length : Roy Smith <roy@panix.com> - 2014-05-17 10:06 -0400
            Re: PEP 8 : Maximum line Length : Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-05-17 15:21 +0100
            Re: PEP 8 : Maximum line Length : Rustom Mody <rustompmody@gmail.com> - 2014-05-17 10:46 -0700

csiph-web