iterator/generator

Mark Lawrence breamoreboy at yahoo.co.uk
Mon Mar 15 04:46:31 EDT 2010


vsoler wrote:
> I am working on a script that reads data from an excel workbook. The
> data is located in a named range whose first row contains the headers.
> It works!!!  I find it superb that python is able to do such things!!!
> 
> Now my questions.
> 
> a. My ranges can in practice be quite big, and although I am happy
> with the speed I get, because I am learning python, I think I could do
> it still a bit better. I think that the line   for i in matriz[1:]:
> could be improved with an iterator/generator, but I am not quite
> certain how I should proceed.

I write this :-
for j, i in enumerate(matriz):
     if j:
         etc...

If there's a better method for some definition of better I'm certain 
we'll quickly get told.

Please see the python docs for the enumerate built-in.

HTH.

Mark Lawrence.

[snip the rest]




More information about the Python-list mailing list