Re: iterator/generator

2010-03-15 Thread Mark Lawrence
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

Re: iterator/generator

2010-03-14 Thread Patrick Maupin
First of all, as Steve Holden mentioned, do look at xlrd. It's awesome. Second, for your (a) question, if you want an iterator, that's quite easy: matriz = iter(matriz) matriz.next() # Discard the first one for i in matriz: This technique works really well, especially if you have sub-loops. Th

Re: iterator/generator

2010-03-14 Thread Steve Holden
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 pro

iterator/generator

2010-03-14 Thread vsoler
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. b. the following lines could be improved by means of a

Re: How to unget a line when reading from a file/stream iterator/generator?

2008-04-29 Thread python
Duncan, > If speed is an issue then it may be better to avoid the test altogether ... > Thanks for your suggestion. Regards, Malcolm -- http://mail.python.org/mailman/listinfo/python-list

Re: How to unget a line when reading from a file/stream iterator/generator?

2008-04-29 Thread Duncan Booth
George Sakkis <[EMAIL PROTECTED]> wrote: > On Apr 28, 10:10 pm, [EMAIL PROTECTED] wrote: >> George, >> >> > Is there an elegant way to unget a line when reading from a >> > file/stream > iterator/generator? >> >> http://aspn.activestate.com/A

Re: How to unget a line when reading from a file/stream iterator/generator?

2008-04-28 Thread George Sakkis
On Apr 28, 10:10 pm, [EMAIL PROTECTED] wrote: > George, > > > Is there an elegant way to unget a line when reading from a file/stream > > iterator/generator? > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/502304 > > That's exactly what I was lookin

Re: How to unget a line when reading from a file/stream iterator/generator?

2008-04-28 Thread python
George, > Is there an elegant way to unget a line when reading from a file/stream > iterator/generator? http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/502304 That's exactly what I was looking for! For those following this thread, the above recipe creates a generic object

Re: How to unget a line when reading from a file/stream iterator/generator?

2008-04-28 Thread George Sakkis
On Apr 28, 2:07 pm, [EMAIL PROTECTED] wrote: > Is there an elegant way to unget a line when reading from a file/stream > iterator/generator? > > By "unget" I mean a way to push back a line into the source stream and > backtrack the iterator/generator one step? > > Th

Re: How to unget a line when reading from a file/stream iterator/generator?

2008-04-28 Thread Arnaud Delobelle
[EMAIL PROTECTED] writes: > Is there an elegant way to unget a line when reading from a file/stream > iterator/generator? > > By "unget" I mean a way to push back a line into the source stream and > backtrack the iterator/generator one step? > > The only alternat

How to unget a line when reading from a file/stream iterator/generator?

2008-04-28 Thread python
Is there an elegant way to unget a line when reading from a file/stream iterator/generator? By "unget" I mean a way to push back a line into the source stream and backtrack the iterator/generator one step? The only alternative I can see is to put my line reading in a while-True loop