Re: Please code review.

2011-08-02 Thread Karim
On 08/02/2011 03:59 PM, Peter Otten wrote: Karim wrote: values = ( (22.5,21.5,121.5), (5615.3,615.3,-615.3), (-2315.7,315.7,415.7) ) it = _xrange_cellnames(rows=len(value), cols=len(values[0])) table.getCellByName(it.next()).setValue(22.5) table.getCellByName(it.next()).setValue(5615.3) table

Re: Please code review.

2011-08-02 Thread Peter Otten
Karim wrote: > values = ( (22.5,21.5,121.5), > (5615.3,615.3,-615.3), > (-2315.7,315.7,415.7) ) > > it = _xrange_cellnames(rows=len(value), cols=len(values[0])) > > table.getCellByName(it.next()).setValue(22.5) > table.getCellByName(it.next()).setValue(5615.3) > table.getCellByName(it.next()).se

Re: Please code review.

2011-08-02 Thread Karim
Thanks Martin, This is the generator expression version. I can use both function generator or generator expression version correction. Cheers Karim On 08/02/2011 02:47 PM, Martin Gracik wrote: def get_cellnames2(rows, cols): rows = range(1, rows + 1) cols = string.ascii_uppercase[:c

Re: Please code review.

2011-08-02 Thread Karim
On 08/02/2011 02:27 PM, Peter Otten wrote: Karim wrote: I need a generator to create the cellname in a excell (using pyuno) document to assign value to the correct cell. Isn't there a way to use a (row, column) tuple directly? If so I'd prefer that. Also, there used to be an alternative format

Re: Please code review.

2011-08-02 Thread Karim
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/

Re: Please code review.

2011-08-02 Thread Karim
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

Re: Please code review.

2011-08-02 Thread Peter Otten
Karim wrote: > I need a generator to create the cellname in a excell (using pyuno) > document to assign value to the correct cell. Isn't there a way to use a (row, column) tuple directly? If so I'd prefer that. Also, there used to be an alternative format to address a spreadsheet cell with som

Re: Please code review.

2011-08-02 Thread Martin Gracik
On Tue, Aug 2, 2011 at 1:45 PM, Karim wrote: > > 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 ins

Re: Please code review.

2011-08-02 Thread Chris Angelico
On Tue, Aug 2, 2011 at 12:45 PM, Karim 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. I

Re: Please code review.

2011-08-02 Thread Paul Kölle
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.

Please code review.

2011-08-02 Thread 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+ (r27