Path: csiph.com!x330-a1.tempe.blueboxinc.net!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.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'char': 0.07; 'indeed,': 0.07; 'subject:code': 0.07; 'wrote:': 0.15; 'chr': 0.16; 'columns': 0.16; 'it...': 0.16; 'simpler.': 0.16; 'pm,': 0.16; 'aug': 0.19; 'simpler': 0.19; 'received:74.125.82.174': 0.19; 'received:mail-wy0-f174.google.com': 0.19; 'seems': 0.20; 'extension': 0.22; 'header:In-Reply-To:1': 0.22; 'code.': 0.22; 'indices': 0.23; 'cheers': 0.23; 'tue,': 0.23; 'there.': 0.25; 'string': 0.26; 'function': 0.26; 'yield': 0.29; 'fact': 0.30; 'implicitly': 0.30; 'thanks': 0.31; 'chris': 0.32; "skip:' 10": 0.32; 'message-id:@gmail.com': 0.32; 'to:addr:python-list': 0.34; 'header:User-Agent:1': 0.34; '...': 0.34; 'probably': 0.35; 'some': 0.37; 'subject:Please': 0.37; 'but': 0.37; 'could': 0.37; 'received:192': 0.38; 'received:google.com': 0.38; 'subject:: ': 0.38; 'should': 0.39; 'received:74.125.82': 0.39; 'to:addr:python.org': 0.39; 'received:74.125': 0.40; 'your': 0.60; 'double': 0.62; 'hand,': 0.76; '02:07': 0.84; '12:45': 0.84; 'blind': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=Hc9lcDt3P1GQE3kWAag73HmbugptbUPlPnAywLVrvFM=; b=ReIejItv+1MVSKUSvWJ/SlETP5VgMDWnpDLcSIzCwgAKM2JB6ltAS5EMMOfXGI7T6Z xE+2Qj180Q8QP6em3zQOZq3CFCO5Dukzj8Fdrds+A92Vj3t18jkcZtGTsuv9EjspsaZ3 wUm4UlorD/8imgIzVKIsHCUbcCEbnTRirAGwQ= Date: Tue, 02 Aug 2011 14:33:32 +0200 From: Karim User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110617 Thunderbird/3.1.11 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Please code review. References: <4E37E34B.5080707@gmail.com> 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.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: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1312288416 news.xs4all.nl 23874 [2001:888:2000:d::a6]:46709 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:10727 Thanks Chris! It seems I am blind I should have seen it... In fact I started with the need (imaginary) to use enumerate() to get some indices but ended in a more simple code. Indeed, your's is simpler. For the double chars extension I will see if I need it in the future. Cheers Karim On 08/02/2011 02:07 PM, Chris Angelico wrote: > On Tue, Aug 2, 2011 at 12:45 PM, Karim wrote: >> ... for char in cellnames.replace('', ' ').split()[:cols]: > for char in cellnames[:cols]: > > Strings are iterable over their characters. Alternatively, you could > use chr and ord, but it's probably cleaner and simpler to have the > string there. It also automatically and implicitly caps your columns > at 26. On the other hand, if you want to support more than 26 columns, > you may want to make your own generator function to yield 'A', 'B',... > 'Z', 'AA', 'AB', etc. > > ChrisA