Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #10726
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <kliateni@gmail.com> |
| 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; 'assign': 0.04; 'string.': 0.04; '(using': 0.05; 'instance': 0.05; 'char': 0.07; 'subject:code': 0.07; 'python': 0.08; 'compute': 0.09; 'syntax': 0.11; 'wrote:': 0.15; '"copyright",': 0.16; '"credits"': 0.16; '"license"': 0.16; '[gcc': 0.16; 'alphabetic': 0.16; 'cell.': 0.16; 'iterator': 0.16; 'linux2': 0.16; 'row': 0.16; 'intermediate': 0.16; 'pm,': 0.16; '>>>': 0.16; 'def': 0.16; 'received:74.125.82.174': 0.19; 'received:mail- wy0-f174.google.com': 0.19; 'header:In-Reply-To:1': 0.22; 'cheers': 0.23; 'code': 0.24; 'string': 0.26; 'function': 0.26; 'paul': 0.28; 'skip:_ 20': 0.28; 'correct': 0.29; 'import': 0.29; 'yield': 0.29; 'thanks': 0.31; 'error': 0.31; "skip:' 10": 0.32; 'apr': 0.32; 'message-id:@gmail.com': 0.32; 'does': 0.32; 'it.': 0.33; 'to:addr:python-list': 0.34; 'instead': 0.34; 'header:User- Agent:1': 0.34; '...': 0.34; 'module.': 0.35; 'some': 0.37; 'subject:Please': 0.37; 'but': 0.37; 'received:192': 0.38; 'received:google.com': 0.38; 'subject:: ': 0.38; 'hello,': 0.38; 'received:74.125.82': 0.39; 'skip:s 20': 0.39; 'to:addr:python.org': 0.39; 'skip:. 10': 0.40; 'received:74.125': 0.40; 'table': 0.40; '02:04': 0.84; 'schrieb': 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=6Bnv8EXRHUeq1+SOoNDX8V9u1HgZib2T6gTzrwTYXXs=; b=G1rA8zD4PqY5oj5AlCVe6e1zHJWJ6Kf0rEQdJLpGTjFj7avOOTvLkDqISMGBjLMYTH y3GqBd1PI/mc+0WuKvjR3neW8OwxDYmtTqXp29F5gyBQsJTjfgaz9pqTRva24wM9kqPB ++vWHxZ+pA6VSuDu2T7DIUxmhOqsE55L6+7s4= |
| Date | Tue, 02 Aug 2011 14:28:01 +0200 |
| From | Karim <kliateni@gmail.com> |
| 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> <j18p4v$og$1@dough.gmane.org> |
| In-Reply-To | <j18p4v$og$1@dough.gmane.org> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 8bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1770.1312288087.1164.python-list@python.org> (permalink) |
| Lines | 59 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1312288087 news.xs4all.nl 23875 [2001:888:2000:d::a6]:40564 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:10726 |
Show key headers only | View raw
Thanks Paul,
I never used string module.
In fact, cellnames.split('') gives a syntax error w/ empty string.
That's why I use the intermediate replace() which accept that.
Cheers
Karim
On 08/02/2011 02:04 PM, Paul Kölle wrote:
> Am 02.08.2011 13:45, schrieb Karim:
>>
>> Hello,
>>
>> I need a generator to create the cellname in a excell (using pyuno)
>> document to assign value to
>> the correct cell. The following code does this but do you have some
>> optimizations
>> on it, for instance to get the alphabetic chars instead of
>> hard-coding it.
> you can use:
> import string
> cellnames = string.ascii_uppercase
>
> not sure why you need the .replace().split() stuff...
>
>
> def _xrange_cellnames(rows, cols):
> cellnames = string.ascii_uppercase
> for row in xrange(1, rows+1):
> for char in cellnames[:rows]:
> yield char + str(row)
>
> cheers
> Paul
>
>
>>
>> Cheers
>> karim
>>
>> Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53)
>> [GCC 4.5.2] on linux2
>> Type "help", "copyright", "credits" or "license" for more information.
>> >>> def _xrange_cellnames(rows, cols):
>> ... """Internal iterator function to compute excell table cellnames."""
>> ... cellnames = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
>> ... for row in xrange(1, rows+1):
>> ... for char in cellnames.replace('', ' ').split()[:cols]:
>> ... yield char + str(row)
>> ...
>> >>> list( _xrange_cellnames(rows=3,cols=4))
>> ['A1', 'B1', 'C1', 'D1', 'A2', 'B2', 'C2', 'D2', 'A3', 'B3', 'C3', 'D3']
>>
>>
>
>
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Please code review. Karim <kliateni@gmail.com> - 2011-08-02 14:28 +0200
csiph-web