Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed3.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.071 X-Spam-Evidence: '*H*': 0.88; '*S*': 0.02; 'nicely': 0.07; 'cc:addr :python-list': 0.11; 'def': 0.12; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'kw:': 0.16; 'repetition': 0.16; 'simplified': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'cc:addr:python.org': 0.22; 'case.': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'does': 0.39; 'though,': 0.39; 'simple,': 0.60; 'simple': 0.61; "you're": 0.61; '20,': 0.68; '2015': 0.84; 'subject:Best': 0.91; 'ware': 0.91; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=YAdubOhRV4aredWJIYhETgfoxb/FAfXycOqh1Zn7lrw=; b=eacyK6b5EwYFleihhEBWItnJQVg86z63sZDvZW4HBd7LKDdpqsma61RBCFpjVbbv+l +N6e36N7R599SJeKuVa3Uxky3lUukgtHcrqREA2I7Ca6DEVq3b7hM7TXGpvZGuX0A2rG xhwFX2FfV89BpNgTVPeEcds5asjEuRTrtl0yedVI76/kOn417TCNbvbRypdUreHPrUql HfrUuhqtcKN1AzmDuhYfZrgxL8bj0b8BpJU5sDrZFu21kxPkaJLsIAAdQ/48YngBiZmT m14OOli7IR5C/q8jXNETC9RD7Wcch8mo0gGtK3SMa8jlfT5s3R4wZwtQKDm7oWic6EAz 2vVg== MIME-Version: 1.0 X-Received: by 10.107.16.32 with SMTP id y32mr37664235ioi.53.1432059233415; Tue, 19 May 2015 11:13:53 -0700 (PDT) In-Reply-To: References: <87siastsby.fsf@Equus.decebal.nl> Date: Wed, 20 May 2015 04:13:53 +1000 Subject: Re: Best way to rewrite Popen From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1432059241 news.xs4all.nl 2969 [2001:888:2000:d::a6]:46599 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:90886 On Wed, May 20, 2015 at 3:55 AM, Zachary Ware wrote: >> def capture_stdout(*a, **kw): >> if 'stdout' not in kw: kw['stdout'] = subprocess.PIPE > > Just a quick note that this line can be simplified nicely to: > > kw.setdefault('stdout', subprocess.PIPE) Yes, in the simple case. That does require pre-evaluating subprocess.PIPE though, which in some situations is an important distinction. But you're right, for something this simple, the repetition is superfluous. Good catch. ChrisA