Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'line:': 0.07; 'input,': 0.09; 'python:': 0.09; 'url:github': 0.09; 'capitalizes': 0.16; 'received:74.55.86': 0.16; 'received:74.55.86.74': 0.16; 'received:smtp.webfaction.com': 0.16; 'received:webfaction.com': 0.16; 'subject:whitespaces': 0.16; 'url:py': 0.16; 'wrote:': 0.17; 'input': 0.18; 'fine,': 0.22; 'this:': 0.23; 'script': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'this?': 0.28; 'kumar': 0.29; 'prints': 0.29; 'spaces': 0.29; "skip:' 10": 0.30; 'file': 0.32; 'word.': 0.33; 'problem': 0.33; 'to:addr:python-list': 0.33; 'subject:?': 0.35; 'does': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'takes': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'first': 0.61; 'here': 0.65; 'biggest': 0.71; 'subject:Any': 0.84; 'url:master': 0.84 Date: Sat, 19 Jan 2013 14:04:03 -0500 From: Mitya Sirenef User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121011 Thunderbird/16.0.1 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Any algorithm to preserve whitespaces? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1358622246 news.xs4all.nl 6914 [2001:888:2000:d::a6]:34922 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:37095 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/