Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'bug': 0.02; 'received:verizon.net': 0.07; 'terry': 0.07; 'attribute': 0.09; 'object.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'am,': 0.13; 'wrote:': 0.15; 'duplicates': 0.16; 'reedy': 0.16; 'repeated': 0.19; 'jan': 0.19; 'otherwise.': 0.22; 'pointed': 0.22; 'header :In-Reply-To:1': 0.22; 'joining': 0.23; 'code': 0.24; 'function': 0.26; 'exercise': 0.28; 'repeatedly': 0.28; 'bound': 0.29; 'object': 0.30; 'example': 0.30; 'description.': 0.30; 'useless': 0.30; 'does': 0.32; 'to:addr:python-list': 0.34; 'header:X -Complaints-To:1': 0.34; 'header:User-Agent:1': 0.34; 'pretty': 0.35; 'file': 0.36; 'but': 0.37; 'received:org': 0.38; 'subject:: ': 0.38; 'execution': 0.38; 'header:Mime-Version:1': 0.39; 'rest': 0.39; 'either': 0.39; 'to:addr:python.org': 0.39; 'give': 0.60; 'restore': 0.64; 'yourself': 0.68; 'subject:The': 0.73; '11:29': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Snippet: The leanest Popen wrapper Date: Wed, 03 Aug 2011 16:20:22 -0400 References: <51b2d157-3fea-4f8e-80b4-e7142629eca8@s21g2000pre.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-74-109-121-73.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20110624 Thunderbird/5.0 In-Reply-To: <51b2d157-3fea-4f8e-80b4-e7142629eca8@s21g2000pre.googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1312402840 news.xs4all.nl 23880 [2001:888:2000:d::a6]:46290 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:10827 On 8/3/2011 11:29 AM, Phlip wrote: > This is either a code snippet, if you like it, or a request for a > critique, if you don't. A learning exercise but pretty useless otherwise. As others pointed out, immediately stripping off \n is a bug relative to *your* function description. Also, you yourself then give an example of joining with \n. But that does not restore the final \n. The rest duplicates the iteration ability of the .stdout file object. For repeated execution of code like process.stdout.readline() you can once create a 'packetized' bound method object like so cmdline = process.stdout.readline and then, without repeating the attribute lookups, repeatedly call cmdline() . -- Terry Jan Reedy