Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python.': 0.02; 'subject:help': 0.07; '22,': 0.09; 'subject:script': 0.09; 'aug': 0.13; 'file,': 0.15; 'all?': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'letters.': 0.16; 'sed': 0.16; 'wed,': 0.16; 'wrote:': 0.17; 'received:209.85.214.174': 0.21; 'script': 0.24; 'header:In-Reply-To:1': 0.25; 'skip:" 20': 0.26; 'topic': 0.27; 'message-id:@mail.gmail.com': 0.27; 'words': 0.29; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'pm,': 0.35; 'received:209.85': 0.35; 'really': 0.36; 'subject:" ': 0.36; 'why': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'easily': 0.39; 'header:Received:5': 0.40; 'first': 0.61; 'leaving': 0.62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=ntz48GD0pwnzXJF6KKN9Qtnfmb260PrqUNejl63sya8=; b=JKmIxJDH6ZrQRBEUjNaNPAKZGzweEm7QjDiOB4fz1CADTsawIl0FHOtpHxZoliD+rt R5OW7CZs5EljJt/MHSxA+qoR3i1iIyQsdyUaMwiGk2bk3d2spaWge20fPlo88OIUQ4he E5sfSy3fE7riGQrgxavJLbrJ+iyIq/HtCv2zdAF4lO7uUKQk9jIFU5nQE8veSCdP6FPx wTZ9q0bARzW66yUk5RPsm0cFgDn/7sKLSZUuajjA5xCImBpObpMhqpfqftPqYqwQELXx FEOQgD4kLN5NCwB0aZG82jNc+1cRLva9ZxM5b3m7qv8UxSnBaC0AkQvqo4kLCcXqm6XS 3nUA== MIME-Version: 1.0 In-Reply-To: References: Date: Wed, 22 Aug 2012 20:41:42 +1000 Subject: Re: help me debug my "word capitalizer" script From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 14 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1345632103 news.xs4all.nl 6850 [2001:888:2000:d::a6]:34241 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:27626 On Wed, Aug 22, 2012 at 8:28 PM, Kamil Kuduk wrote: >> Purpose of the script: >> To capitalize the first letter of any word in a given file, leaving >> words which have 3 or less letters. > > First or all? If first and this is the only purpose of the script you > can easily use sed: > less file.txt | sed -e "s/\b\([a-z]\{4,\}\)/\u\1/g" Why less? Why not just redirect input? Though, this isn't really on topic for Python. ChrisA