Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'elif': 0.04; '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; 'subsequent': 0.15; 'bieber': 0.16; 'case...': 0.16; 'declaimed': 0.16; 'email addr:ix.netcom.com': 0.16; 'email name:wlfraed': 0.16; 'from:addr:ix.netcom.com': 0.16; 'from:addr:wlfraed': 0.16; 'from:name:dennis lee bieber': 0.16; 'lowercase': 0.16; 'received:66.245': 0.16; 'received:dsl.mindspring.com': 0.16; 'received:mindspring.com': 0.16; 'received:wlfraed': 0.16; 'url:netcom': 0.16; 'url:wlfraed': 0.16; 'wulfraed': 0.16; 'language': 0.17; 'suggest': 0.20; 'url:home': 0.21; '-0700': 0.23; 'sep': 0.23; 'lee': 0.28; 'sat,': 0.28; 'definition': 0.30; 'basically,': 0.30; "skip:' 10": 0.30; 'list': 0.32; 'word.': 0.32; 'words,': 0.32; 'to:addr:python-list': 0.33; 'header:X -Complaints-To:1': 0.35; 'anything': 0.36; 'charset:us-ascii': 0.36; 'received:org': 0.38; 'subject:: ': 0.39; 'header:Mime- Version:1': 0.39; 'else': 0.39; 'goes': 0.39; 'to:addr:python.org': 0.39; "i'd": 0.40; 'skip:n 30': 0.62; 'lower': 0.64; 'dennis': 0.77 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: Doctest failing Date: Sat, 10 Sep 2011 16:25:42 -0700 Organization: > Bestiaria Support Staff < References: <678b89fd-82f4-4080-8b36-e4d0ba30cdbf@o9g2000vbo.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: user-11fa4e5.dsl.mindspring.com X-Newsreader: Forte Agent 3.3/32.846 X-No-Archive: YES 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: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1315697157 news.xs4all.nl 2411 [2001:888:2000:d::a6]:35836 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:13088 On Sat, 10 Sep 2011 04:20:17 -0700 (PDT), Tigerstyle declaimed the following in gmane.comp.python.general: > title_split = title.strip().lower().split() > for word in title_split: > if title_split[0] in small_words: > new_title.append(word.title()) title_split[0] will never change, so if it is one of the small words, then all subsequent words will also be treated to this branch. > elif word in small_words: > new_title.append(word.lower()) You already lowercased all the words before splitting, so this is applying lowercase to a known lowercase word > else: > new_title.append(word.title()) > return(' '.join(new_title)) > I'd suggest looking up the definition of enumerate() in the language documentation... It will give you a simple way to know if you are looking at the first word. Basically, you want to title-case the word IF it is the first word OR the word is NOT in the list of lowercase words; anything else goes through as lower case... -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/