Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!xlned.com!feeder5.xlned.com!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.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; 'function,': 0.07; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'nicely': 0.09; 'received:gator410.hostgator.com': 0.09; '~ethan~': 0.09; 'debugging': 0.13; 'def': 0.15; 'complicated,': 0.16; 'wrote:': 0.16; 'header:In-Reply-To:1': 0.22; 'sep': 0.23; 'pm,': 0.24; 'function': 0.27; 'needed,': 0.28; 'sat,': 0.28; 'conditional': 0.30; 'logic': 0.30; 'chris': 0.32; 'to:addr :python-list': 0.33; 'named': 0.33; '...': 0.34; 'header:User- Agent:1': 0.34; 'but': 0.37; 'subject:: ': 0.39; 'manually': 0.39; 'word,': 0.39; 'to:addr:python.org': 0.39; 'sense': 0.39; "i'd": 0.40; 'more': 0.60; 'your': 0.61; 'received:websitewelcome.com': 0.64; 'here': 0.65; 'received:184': 0.67; '1st': 0.70; '10:24': 0.84; 'ware': 0.91 Date: Sun, 11 Sep 2011 11:43:38 -0700 From: Ethan Furman User-Agent: Thunderbird 2.0.0.24 (Windows/20100228) MIME-Version: 1.0 To: python-list@python.org Subject: Re: Doctest failing References: <678b89fd-82f4-4080-8b36-e4d0ba30cdbf@o9g2000vbo.googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator410.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-BWhitelist: no X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: c-67-170-168-84.hsd1.or.comcast.net ([192.168.74.5]) [67.170.168.84]:4878 X-Source-Auth: ethan+stoneleaf.us X-Email-Count: 1 X-Source-Cap: dG9idWs7dG9idWs7Z2F0b3I0MTAuaG9zdGdhdG9yLmNvbQ== 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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1315766676 news.xs4all.nl 2544 [2001:888:2000:d::a6]:51865 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:13140 Chris Angelico wrote: > On Sat, Sep 10, 2011 at 10:24 PM, Alister Ware > wrote: >> Ignoring the docttests my process would be to process each word & then >> manually capitalize he 1st word, .I would als0 use a comprehension as >> makes for cleaner code:- >> >> def capitalize(word): >> if word in small_words: >> return word >> else: >> return word.title() > > And I'd do this with a lambda, but that's just me. Of course, if your > logic is more complicated, it makes more sense to keep it in a named > function, but a single conditional call can fit nicely into a lambda. Lambdas are great when needed, but if don't *need* it, and you have more than a few, debugging can be a nightmare... "Okay, so this is function ... and that is function ... and over here we also have function ... ARGH!" ~Ethan~