Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin3!goblin1!goblin.stu.neva.ru!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'broken': 0.04; 'causing': 0.04; 'skip:[ 20': 0.04; 'subject:Python': 0.06; 'file)': 0.09; 'filename': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'repeated': 0.09; 'jan': 0.12; 'files"': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'subject:breaking': 0.16; 'wrote:': 0.18; 'examples': 0.20; 'fit': 0.20; '(the': 0.22; 'header:User- Agent:1': 0.23; "i've": 0.25; 'values': 0.27; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'forgot': 0.30; 'towards': 0.31; 'another': 0.32; 'common': 0.35; 'case,': 0.35; 'add': 0.35; 'processed': 0.36; 'subject:?': 0.36; 'hi,': 0.36; 'two': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'previous': 0.38; 'does': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'received:org': 0.40; 'break': 0.61; 'received:173': 0.61; 'first': 0.61; 'name': 0.63; 'end.': 0.84; 'factoring': 0.84; 'received:fios.verizon.net': 0.84; 'subject:long': 0.84; 'victor': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Python and PEP8 - Recommendations on breaking up long lines? Date: Wed, 27 Nov 2013 22:03:11 -0500 References: <34479463-b8a8-4417-9989-cd29369461c2@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-254-207.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 In-Reply-To: <34479463-b8a8-4417-9989-cd29369461c2@googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1385607813 news.xs4all.nl 15925 [2001:888:2000:d::a6]:56386 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:60667 On 11/27/2013 9:03 PM, Victor Hooi wrote: > Hi, > > Also, forgot two other examples that are causing me grief: > > cur.executemany("INSERT INTO foobar_foobar_files VALUES (?)", > [[os.path.relpath(filename, foobar_input_folder)] for filename in filenames]) > > I've already broken it up using the parentheses, not sure what's the tidy way to break it up again to fit under 80? In this case, the 80-character mark is hitting me around the "for filename" towards the end. add another linebreak, you are still inside the parens. > and: > > if os.path.join(root, file) not in previously_processed_files and os.path.join(root, file)[:-3] not in previously_processed_files: > > In this case, the 80-character mark is actually partway through "previously processed files" (the first occurrence)... You can add parens. In this case, factoring out the common subexpression and replaced the repeated long name does the job. p = os.path.join(root, file) ppf = previously_processed_files if p not in ppf and p[:-3] not in ppf: [snip previous post] -- Terry Jan Reedy