Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'method.': 0.05; 'chunk': 0.07; 'parameter': 0.07; 'subject:file': 0.07; 'backwards': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'sep': 0.09; 'subject:python': 0.11; 'dangling': 0.16; 'eckhardt': 0.16; 'file;': 0.16; 'marker': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'sense...': 0.16; 'subject:API': 0.16; 'string': 0.17; 'implementing': 0.17; 'written': 0.20; "i've": 0.23; 'second': 0.24; 'handling': 0.27; "doesn't": 0.28; 'header:X-Complaints-To:1': 0.28; 'appending': 0.29; 'optional': 0.29; 'read,': 0.29; 'mode': 0.30; 'position.': 0.30; 'relative': 0.30; 'code': 0.31; 'file': 0.32; 'could': 0.32; '+0200,': 0.33; 'url:home': 0.33; 'handle': 0.33; 'to:addr:python-list': 0.33; 'text': 0.34; 'done': 0.34; 'third': 0.34; 'next': 0.35; 'received:org': 0.36; 'but': 0.36; 'charset:us-ascii': 0.36; 'subject:: ': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'end': 0.40; 'think': 0.40; 'ever': 0.63; 'more': 0.63; 'dennis': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: python file API Date: Tue, 25 Sep 2012 04:19:03 -0400 Organization: > Bestiaria Support Staff < References: <0ec1fe2e-890c-4e25-8047-4cb8bee0aa95@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-76-253-103-108.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 3.3/32.846 X-No-Archive: YES X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1348561141 news.xs4all.nl 6843 [2001:888:2000:d::a6]:55112 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:30045 On Tue, 25 Sep 2012 08:22:05 +0200, Ulrich Eckhardt declaimed the following in gmane.comp.python.general: > Am 24.09.2012 23:49, schrieb Dave Angel: > > And what approach would you use for positioning relative to > > end-of-file? That's currently done with an optional second > > parameter to seek() method. > > Negative indices. > Which still doesn't handle the third seek mode -- relative to current position. I don't think I've ever written code to seek from the end of a file -- but moving /x/-bytes from where the file currently is makes more sense... For example, implementing chunked reading of a text file; instead of handling a dangling partial line by holding it and appending the next chunked read, one could use string methods to find the offset of the last new-line marker relative to the length of the chunk and do a relative seek backwards to position the next chunk at the start of that partial line. -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/