Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!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; 'intermediate': 0.05; 'subject:help': 0.07; 'chunks': 0.09; 'subject:skip:m 10': 0.09; 'subject:string': 0.09; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'least,': 0.16; 'roy': 0.16; 'sure.': 0.16; 'wrote:': 0.17; 'jan': 0.18; 'split': 0.23; 'header:In-Reply- To:1': 0.25; 'skip:" 20': 0.26; 'values': 0.26; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'lines': 0.28; 'chris': 0.28; 'could': 0.32; 'print': 0.32; 'to:addr :python-list': 0.33; 'received:google.com': 0.34; 'received:209.85.220': 0.35; 'subject:?': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'skip:( 30': 0.38; 'easier': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'matter': 0.61; 'subject:Need': 0.61; 'want,': 0.65; 'subject:. ': 0.66; 'smith': 0.71; 'article': 0.78; '2013': 0.84; 'dozen': 0.91 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=9nWPrpMKEAh2OIfbR/VZG1IHzr3klx45JvGyALOzaMg=; b=SW+y6CBtp2xsm2nss+SNG/5OGN1IaCGClkllNrUAKOsY17dvKtTDNmnMWcvBPsHkFn GRQPPaQQuELL+cY0dXPou56C/V/Re+7vnkvP+1WfJRA95IQDbdgVF+S3z9yB4qfmy2Z/ JZZI9sNmXQ35dnzpvuIY7e3c4BZLuCK4FXoG8PHuNmrj+eHAtfw+2hwyOMdMZxivIHdk +f3tiM9dJ0GEbRAJj0h2EbANHR7Buf7jZBkkYeLUaCyeUKCdlN420Bbs6OTBCFEsxl1U q+t64M+Ze3lM/Z8J7yWQiA7/yrFglvVSSHPRXRyPC5clxQRgenwjjnOhnCgWjZRVKpxB ftRw== MIME-Version: 1.0 In-Reply-To: References: Date: Sun, 6 Jan 2013 01:47:32 +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: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1357397255 news.xs4all.nl 6980 [2001:888:2000:d::a6]:45450 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:36177 On Sun, Jan 6, 2013 at 1:30 AM, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> result = "".join([x[int(x[0])+1:] for x in ("0"+s).replace("-","+").split("+")]) > > That's exceedingly clever. But bordering on line noise. At the very > least, I would break it up into a couple of lines to make it easier to > understand (plus you can print out the intermediate values to see what's > going on): > > chunks = ("0"+s).replace("-","+").split("+") > result = "".join([x[int(x[0])+1:] for x in chunks] Sure. You can always split a one-liner to taste, doesn't much matter where. You could split it majorly into half a dozen lines if you want, doesn't make a lot of diff. It'll work the same way :) ChrisA