Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #13088
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Subject | Re: Doctest failing |
| Date | 2011-09-10 16:25 -0700 |
| Organization | > Bestiaria Support Staff < |
| References | <678b89fd-82f4-4080-8b36-e4d0ba30cdbf@o9g2000vbo.googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.953.1315697157.27778.python-list@python.org> (permalink) |
On Sat, 10 Sep 2011 04:20:17 -0700 (PDT), Tigerstyle
<laddosingh@gmail.com> 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/
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Doctest failing Tigerstyle <laddosingh@gmail.com> - 2011-09-10 04:20 -0700
Re: Doctest failing Mel <mwilson@the-wire.com> - 2011-09-10 07:43 -0400
Re: Doctest failing Tigerstyle <laddosingh@gmail.com> - 2011-09-11 09:36 -0700
Re: Doctest failing Peter Otten <__peter__@web.de> - 2011-09-10 13:47 +0200
Re: Doctest failing ting@thsu.org - 2011-09-10 19:12 -0700
Re: Doctest failing Tigerstyle <laddosingh@gmail.com> - 2011-09-11 09:42 -0700
Re: Doctest failing Thomas Jollans <t@jollybox.de> - 2011-09-10 13:50 +0200
Re: Doctest failing Tigerstyle <laddosingh@gmail.com> - 2011-09-11 09:39 -0700
Re: Doctest failing Alister Ware <alister.ware@ntlworld.com> - 2011-09-10 12:24 +0000
Re: Doctest failing Chris Angelico <rosuav@gmail.com> - 2011-09-11 01:56 +1000
Re: Doctest failing Tigerstyle <laddosingh@gmail.com> - 2011-09-11 09:40 -0700
Re: Doctest failing Ethan Furman <ethan@stoneleaf.us> - 2011-09-11 11:43 -0700
Re: Doctest failing Chris Angelico <rosuav@gmail.com> - 2011-09-12 11:03 +1000
Re: Doctest failing Ben Finney <ben+python@benfinney.id.au> - 2011-09-12 11:37 +1000
Re: Doctest failing Chris Angelico <rosuav@gmail.com> - 2011-09-12 13:06 +1000
Re: Doctest failing Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-09-12 14:29 +1000
Re: Doctest failing Terry Reedy <tjreedy@udel.edu> - 2011-09-10 13:59 -0400
Re: Doctest failing Tigerstyle <laddosingh@gmail.com> - 2011-09-11 04:46 -0700
Re: Doctest failing Terry Reedy <tjreedy@udel.edu> - 2011-09-11 13:03 -0400
Re: Doctest failing Terry Reedy <tjreedy@udel.edu> - 2011-09-10 15:36 -0400
Re: Doctest failing Peter Otten <__peter__@web.de> - 2011-09-10 22:49 +0200
Re: Doctest failing Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-09-10 16:25 -0700
Re: Doctest failing Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-09-10 23:18 -0700
Re: Doctest failing Tigerstyle <laddosingh@gmail.com> - 2011-09-11 09:43 -0700
Re: Doctest failing Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-09-11 12:37 -0700
csiph-web