Please code review.

Karim kliateni at
Tue Aug 2 13:45:15 CEST 2011


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 
on it, for instance to get the alphabetic chars instead of hard-coding it.


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."""
...     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']

More information about the Python-list mailing list