Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nntp-feed.chiark.greenend.org.uk!ewrotcd!news.nosignal.org!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.022 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'subject:help': 0.07; 'subject:skip:m 10': 0.09; 'subject:string': 0.09; 'ah,': 0.16; 'did.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'roy': 0.16; 'wrote:': 0.17; 'jan': 0.18; 'changes': 0.20; 'fairly': 0.21; 'explicit': 0.22; 'split': 0.23; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'found.': 0.27; 'message-id:@mail.gmail.com': 0.27; 'received:209.85.212': 0.28; 'run': 0.28; 'changed.': 0.29; 'case,': 0.29; 'character': 0.29; 'to:addr:python-list': 0.33; 'point.': 0.33; 'received:google.com': 0.34; 'clear': 0.35; 'direction': 0.35; 'faster': 0.35; 'doing': 0.35; 'subject:?': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'but': 0.36; 'why': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'subject:Need': 0.61; 'subject:. ': 0.66; 'smith': 0.71; '2013': 0.84; 'clearer': 0.84 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=GmTMkDnpU96gbsy8W6qWqjtZmqhkswVy0qTOiyhJ5BU=; b=gDUFs30I6eVpiXHfRqCrume0GII9IGjXC38qUl69ZZs7yHkObNWV9GvJMJXX6H1XM5 PZ99jwbMhNkt85nWxGvfjHdvBcQOXfLglVI7Qq07JH9akTrW1zPn6at06wh22AEMSlAi sPy+F5DAUxRXPFrBRlwK72S/TUGZTwLB2w76+o2SbbvCHcRBQFYPpyrYvweqT6UiZZbn /lLU4l3mxl//G+alyCWIS9EcXg5fU4SQmZh1K0H99csScnOkHpER/jzcvhQ49w5xpMht VDkMe61h+sbzX4qDNkBKFIdtQaFYEVmprXqLM+B0WZE0sCEk7Fs5kU3IZFROnagbHGI2 wSdA== MIME-Version: 1.0 In-Reply-To: References: Date: Sun, 6 Jan 2013 02:09:24 +1100 Subject: Re: Need a specific sort of string modification. Can someone help? 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.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: 10 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1357398573 news.xs4all.nl 6972 [2001:888:2000:d::a6]:51758 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:36179 On Sun, Jan 6, 2013 at 2:03 AM, Roy Smith wrote: > That's why I chose to split this where I did. It was where the scan > direction changed. Ah, good point. In any case, this is a fairly simple and clear way of doing things; it may or may not run faster than the explicit state machine, but IMHO it's a lot clearer to read a split() than something that changes state when a particular character is found. ChrisA