Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'file)': 0.07; 'subject:help': 0.07; '22,': 0.09; 'grep': 0.09; 'subject:script': 0.09; 'yeah,': 0.09; 'cc:addr:python-list': 0.10; 'aug': 0.13; 'line)': 0.16; 'wed,': 0.16; 'wrote:': 0.17; 'received:209.85.214.174': 0.21; 'file:': 0.22; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header :In-Reply-To:1': 0.25; 'skip:" 20': 0.26; 'topic': 0.27; 'message- id:@mail.gmail.com': 0.27; 'chris': 0.28; 'print': 0.32; 'like:': 0.33; 'received:google.com': 0.34; 'pm,': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'really': 0.36; 'subject:" ': 0.36; 'why': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'received:209.85.214': 0.39; 'header:Received:5': 0.40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=y8Zh7J7yj+VpFCufgTREE1rRdpiE+hdTrC+ZMN4hQDY=; b=hbBvk8XA11Bq+Q11M0MZjbBKjiBvpDuBvRUaVhHfCMtygHMr/T031Et7SmrwsBcmB5 SR9es0/m4YBEG70yevkW1MCy4/GvJ2L6bAFtui1Pld94Gmvl2zDSg4Zp4vYxrJjE1Rf4 dv8m+EI6U4ofPA3p7L9nnwnxy4aOaBs4rc7TxJOGgNsL6RgIUvqNxDXu4xX5ktBIwmoQ iBgcaC1dG9+G9/F0BwUqpBKfjaUTNjWwwVQ0OSoL/Tikt6BHUBsO149W7Uh7f7jBhNcl z7YXpZP2jcZdf3jIDv3Z24g9zW3SVkw/PfPJOCfwFMbGxyYfnab3A/apd3U+dJfbwduj AZgQ== MIME-Version: 1.0 In-Reply-To: References: From: Kamil Kuduk Date: Wed, 22 Aug 2012 13:06:06 +0200 Subject: Re: help me debug my "word capitalizer" script To: Chris Angelico Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 12 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1345633589 news.xs4all.nl 6974 [2001:888:2000:d::a6]:39619 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:27627 On Wed, Aug 22, 2012 at 12:41 PM, Chris Angelico wrote: > Why less? Why not just redirect input? Yeah, my bad, I somehow used to do it, for grep too, and I know that this is slower > Though, this isn't really on topic for Python. I would still go with regexp, something like: with open('myfile.txt', 'rw) as file: print "".join(re.sub(r'\w{3,}', lambda(match): match.group(0).title(), line) for line in file)