Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python.': 0.02; 'bash': 0.07; 'function,': 0.07; 'python': 0.09; 'generators': 0.09; 'grep': 0.09; 'language': 0.14; '*only*': 0.16; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'stuff.': 0.16; 'uniq': 0.16; 'url:dabeaz': 0.16; 'wrote:': 0.17; 'shell': 0.18; 'sort': 0.21; 'trying': 0.21; 'script': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'rest': 0.28; 'agreed.': 0.29; 'function.': 0.33; 'like:': 0.33; 'to:addr :python-list': 0.33; 'data,': 0.35; 'pm,': 0.35; 'too.': 0.35; 'something': 0.35; 'received:org': 0.36; 'message-id:@gmail.com': 0.36; 'programmers': 0.36; 'should': 0.36; 'execute': 0.37; 'option': 0.37; 'moment': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'header:Received:5': 0.40; 'most': 0.61; 'here:': 0.62; 'subject:...': 0.63; 'great': 0.64; 'cut': 0.71; 'commands.': 0.84; 'darn': 0.84 X-Virus-Scanned: amavisd-new at torriefamily.org Date: Tue, 05 Feb 2013 22:07:33 -0700 From: Michael Torrie User-Agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.12) Gecko/20130105 Thunderbird/10.0.12 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Opinion on best practice... References: <207d17ce-4bc7-487c-acde-6a7b9f66002b@googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1360127270 news.xs4all.nl 6876 [2001:888:2000:d::a6]:59341 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:38255 On 02/05/2013 08:32 PM, Nobody wrote: > A shell script is only the better option if (almost) the *only* thing the > script needs to do is to execute commands. > > The moment you start trying to "process" data, it's time to put up with > the verbosity of subprocess.Popen() so that you can use a well-designed > language for the rest of it. Agreed. And most of the time a script in bash is going to do something like: grep blah /from/file | cut -f 1 -d ' ' | uniq | sort Python generators happen to be very efficient at recreating this sort of thing entirely in python. A great presentation that all system programmers should read is found here: http://www.dabeaz.com/generators/ Very cool stuff. Grep is just a generator function. cut is just a generator function, and so on. And it can be pretty darn fast too.