Using xreadlines
Roy H. Han
starsareblueandfaraway at gmail.com
Fri Feb 27 15:04:43 EST 2009
More information about the Python-list mailing list
Fri Feb 27 15:04:43 EST 2009
- Previous message (by thread): Using xreadlines
- Next message (by thread): factoring wx.Image
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, Feb 27, 2009 at 12:20 PM, Scott David Daniels <Scott.Daniels at acm.org> wrote: > (1) Please do not top post in comp.lang.python, it violates conventions. > > Brett Hedges (should have written): >> bearophile wrote: ... >>> >>> You can also keep track of the absolute position of the lines in the >>> file, etc, or step > >>> back looking for newlines, etc, but it's not handy.... >> >> How would I keep track of the absolute position of the lines? > >> I have tried to use the files.seek() command with the files.tell() >> command and it does not seem to work. The files.tell() command seems >> to give me a number but when I use the files.next() command with >> xreadlines it does not change the line number the next time I use >> files.tell(). > > The answer to your question depends on what version of Python you are > running. Give python version and platform to any question when you > don't _know_ they are irrelevant. > > If you want an answer without any other input, try this: > > The simplest way to solve this for the moment is (re)defining > xreadlines: > > def xreadlines(source): > for line in iter(src.readline, ''): > yield line > > --Scott David Daniels > Scott.Daniels at Acm.Org > -- > http://mail.python.org/mailman/listinfo/python-list > Sorry for top-posting. http://en.wikipedia.org/wiki/Posting_style
- Previous message (by thread): Using xreadlines
- Next message (by thread): factoring wx.Image
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list