Please code review.

K

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.

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..... """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)
....['A1', 'B1', 'C1', 'D1', 'A2', 'B2', 'C2', 'D2', 'A3', 'B3', 'C3', 'D3']
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top