Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #37095 > unrolled thread
| Started by | Mitya Sirenef <msirenef@lightbird.net> |
|---|---|
| First post | 2013-01-19 14:04 -0500 |
| Last post | 2013-01-19 14:04 -0500 |
| Articles | 1 — 1 participant |
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: Any algorithm to preserve whitespaces? Mitya Sirenef <msirenef@lightbird.net> - 2013-01-19 14:04 -0500
| From | Mitya Sirenef <msirenef@lightbird.net> |
|---|---|
| Date | 2013-01-19 14:04 -0500 |
| Subject | Re: Any algorithm to preserve whitespaces? |
| Message-ID | <mailman.697.1358622246.2939.python-list@python.org> |
On 01/19/2013 05:13 AM, Santosh Kumar wrote:
> I have a working script which takes argv[1] as an input, deassembles
> each line, and then each word. Then after it capitalizes all its word
> (upcases the first letter) and then prints it out on the stdout.
>
> That script does the capitalization work fine, but, when it reassemble
> the the words, it does it like this:
>
> lines.append(' '.join(words))
>
> The biggest problem is, even when the input file has many spaces, it
> strips it down to one.
>
> A file with this line:
>
> This line contains many spaces
> becomes:
>
> This Line Contains Many Spaces
>
>
> The whole script will look clumsy here. I have put it up on GitHub,
> here is it: https://github.com/santosh/capitalizr.py/blob/master/capitalizr
You know that mystr.title() can do this?
- m
--
Lark's Tongue Guide to Python: http://lightbird.net/larks/
Back to top | Article view | comp.lang.python
csiph-web