Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #27631 > unrolled thread
| Started by | Santosh Kumar <sntshkmr60@gmail.com> |
|---|---|
| First post | 2012-08-22 18:30 +0530 |
| Last post | 2012-08-22 07:46 -0700 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: help me debug my "word capitalizer" script Santosh Kumar <sntshkmr60@gmail.com> - 2012-08-22 18:30 +0530
Re: help me debug my "word capitalizer" script Rebelo <puntabluda@gmail.com> - 2012-08-22 07:46 -0700
Re: help me debug my "word capitalizer" script Terry Reedy <tjreedy@udel.edu> - 2012-08-22 13:40 -0400
Re: help me debug my "word capitalizer" script Rebelo <puntabluda@gmail.com> - 2012-08-22 07:46 -0700
| From | Santosh Kumar <sntshkmr60@gmail.com> |
|---|---|
| Date | 2012-08-22 18:30 +0530 |
| Subject | Re: help me debug my "word capitalizer" script |
| Message-ID | <mailman.3647.1345640467.4697.python-list@python.org> |
OK! The bug one fixed. Thanks to Andreas Perstinger. Let's move to Bug #2: 2. How do I escape the words that are already in uppercase? For example: The input file has this: NASA The script changes this to: Nasa Is it possible to make this script look at a word, see if its first character is capitalized, if capitalized then skip that word. If not do the processing? I don't wan to use regex? Do I need it?
[toc] | [next] | [standalone]
| From | Rebelo <puntabluda@gmail.com> |
|---|---|
| Date | 2012-08-22 07:46 -0700 |
| Message-ID | <035e81d4-8e43-40fd-a0fa-c60b28f0703a@googlegroups.com> |
| In reply to | #27631 |
> Let's move to Bug #2:
>
> 2. How do I escape the words that are already in uppercase? For example:
>
>
>
> The input file has this:
>
> NASA
>
>
>
> The script changes this to:
>
> Nasa
>
>
>
> Is it possible to make this script look at a word, see if its first
>
> character is capitalized, if capitalized then skip that word. If not
>
> do the processing? I don't wan to use regex? Do I need it?
change:
words[i] = word.capitalize()
into:
if word != word.upper() :
words[i] = word.capitalize()
[toc] | [prev] | [next] | [standalone]
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2012-08-22 13:40 -0400 |
| Message-ID | <mailman.3671.1345657293.4697.python-list@python.org> |
| In reply to | #27640 |
On 8/22/2012 10:46 AM, Rebelo wrote: >> Is it possible to make this script look at a word, see if its first >> character is capitalized, if capitalized then skip that word. Unicode has two 'capital' concepts: 'uppercase' and 'titlecase'. They are the same for latin chars but not for all alphabets. >> I don't wan to use regex? Do I need it? No. It may or may not be easier. > change: > words[i] = word.capitalize() > > into: > if word != word.upper() : > words[i] = word.capitalize() Still buggy >>> s = 'CamelCase' >>> if s != s.upper(): s = s.capitalize() >>> s 'Camelcase' use "if not word[0].isupper:..." or "if word[0].islower This will still .capitalize() 'weirdWord' to 'Weirdword'. If you do not want that, only change the first letter. >>> s = 'weirdWord' >>> if s[0].islower(): s = s[0].upper()+s[1:] >>> s 'WeirdWord' -- Terry Jan Reedy
[toc] | [prev] | [next] | [standalone]
| From | Rebelo <puntabluda@gmail.com> |
|---|---|
| Date | 2012-08-22 07:46 -0700 |
| Message-ID | <mailman.3653.1345646767.4697.python-list@python.org> |
| In reply to | #27631 |
> Let's move to Bug #2:
>
> 2. How do I escape the words that are already in uppercase? For example:
>
>
>
> The input file has this:
>
> NASA
>
>
>
> The script changes this to:
>
> Nasa
>
>
>
> Is it possible to make this script look at a word, see if its first
>
> character is capitalized, if capitalized then skip that word. If not
>
> do the processing? I don't wan to use regex? Do I need it?
change:
words[i] = word.capitalize()
into:
if word != word.upper() :
words[i] = word.capitalize()
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web