Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #10727
| Date | 2011-08-02 14:33 +0200 |
|---|---|
| From | Karim <kliateni@gmail.com> |
| Subject | Re: Please code review. |
| References | <4E37E34B.5080707@gmail.com> <CAPTjJmqeCQxh4tY1+F5mNRQ9EbAx8m5Bg6vjEUE6=ibgDC9OgA@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1771.1312288416.1164.python-list@python.org> (permalink) |
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<kliateni@gmail.com> 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
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Please code review. Karim <kliateni@gmail.com> - 2011-08-02 14:33 +0200
csiph-web