Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Any algorithm to preserve whitespaces?

Reply
Thread Tools

Re: Any algorithm to preserve whitespaces?

 
 
Mitya Sirenef
Guest
Posts: n/a
 
      01-19-2013
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/capitaliz...ter/capitalizr


You know that mystr.title() can do this?

- m


--
Lark's Tongue Guide to Python: http://lightbird.net/larks/

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Any algorithm to preserve whitespaces? Peter Otten Python 0 01-23-2013 09:46 AM
Re: Any algorithm to preserve whitespaces? Santosh Kumar Python 0 01-23-2013 09:20 AM
Re: Any algorithm to preserve whitespaces? Lie Ryan Python 0 01-19-2013 10:26 AM
Any algorithm to preserve whitespaces? Santosh Kumar Python 0 01-19-2013 10:13 AM
FileUtils - :preserve does not preserve mtime of directories on Windoze Grzegorz Chrupala Ruby 2 06-30-2003 07:38 AM



Advertisments