Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'syntax': 0.03; 'subject:Python': 0.05; 'grep': 0.09; 'immutable': 0.09; 'output,': 0.09; 'someone,': 0.09; 'sure,': 0.09; 'tuple': 0.09; '1:09': 0.16; 'color.': 0.16; 'egrep': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'highlight': 0.16; 'immutability': 0.16; 'record,': 0.16; 'roy': 0.16; 'theorist': 0.16; 'tuple,': 0.16; 'whatever,': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'appears': 0.18; 'received:209.85.214.174': 0.21; 'subject:Questions': 0.22; 'header:In-Reply-To:1': 0.25; 'first,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'lines': 0.28; "i'm": 0.29; 'maybe': 0.29; 'function': 0.30; 'error': 0.30; 'point': 0.31; 'gets': 0.32; 'skip:- 10': 0.32; 'anywhere': 0.33; 'purposes,': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'filter': 0.35; 'nov': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'tool': 0.36; 'but': 0.36; "i'll": 0.36; 'keeps': 0.37; 'maintaining': 0.37; 'quite': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'header:Received:5': 0.40; 'red': 0.60; 'most': 0.61; 'different': 0.63; 'obvious': 0.71; 'smith': 0.71; 'inventor': 0.84; 'subject:Interview': 0.84 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:to :content-type; bh=c4+PGhMmyEfStXdtWF1QErL6cFBhpf0uR3FvMjZ/MMA=; b=MH7f0XbfXDY/h1wF0jCFq6EJQpAiqUvmCUS3nFZEYWgJ7Vgt2X2mTaklW5lC+BQCw5 L9oFeF+7w3nLHZZqAk3rNMGovmSO7eUZNU34X3ieMcQDNYoCoEPZ/AfMewmkt9ZDWruo Vk3JK4B2SnIpMZ72PmGSYHmgGQUSlrcJ0Q7xO2r0XxG/9Q45Lc2FszKj52r1UjS5z92s qZpAeMWq+rnOAegGtyKNduXCU2XOb0syX0qdHiWPjEPtDXYuSuPFKPozEvkZmXxVgUsA fwpg3y7nDeCcFDZE9EeL8HwMjVyzFMPy/0uftQaeu1BdtToA/4I087FGpjCxnCIvmv0I oGkw== MIME-Version: 1.0 In-Reply-To: References: <1193768041.349129.26350@v3g2000hsg.googlegroups.com> <55443eb7-847c-4f4c-8d04-1e6b507aac00@googlegroups.com> <50a8acdc$0$29978$c3e8da3$5496439d@news.astraweb.com> <50a911ec$0$29978$c3e8da3$5496439d@news.astraweb.com> <50a97de0$0$29983$c3e8da3$5496439d@news.astraweb.com> Date: Mon, 19 Nov 2012 13:18:18 +1100 Subject: Re: Python Interview Questions From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1353291501 news.xs4all.nl 6852 [2001:888:2000:d::a6]:39826 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:33524 On Mon, Nov 19, 2012 at 1:09 PM, Roy Smith wrote: > The theorist understands that a chisel and a screwdriver were intended > for different purposes, but the pragmatist gets the paint can open. A good tool can always be used in ways its inventor never intended - and it will function as its user expects. $ some_program | egrep --color=always '(ERROR|^)' will highlight the word ERROR in red anywhere it appears in the program's output, while maintaining all other lines without color. Not normal use of grep, to be sure, but quite functional. A tuple may have been intended to be a record, a struct, whatever, but it is what it is, and I'll use one any time it's the best tool for the job. Maybe its immutability is critical; or maybe it's just the most convenient syntax and all I care about is that it be iterable. But when I'm explaining grep to someone, I'll describe it as a filter that keeps only some lines from the original, and when I describe a tuple, I'll point out that it's immutable and (potentially) hashable. The obvious first, the unobvious later. ChrisA