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<kliat...@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

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to