Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!eweka.nl!hq-usenetpeers.eweka.nl!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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; 'python.': 0.02; 'python,': 0.02; 'attribute': 0.05; 'attributes': 0.07; 'subject:file': 0.07; 'api': 0.09; 'abstraction': 0.09; "ain't": 0.09; 'broke': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:python': 0.11; 'suggest': 0.11; 'file,': 0.15; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'simplified': 0.16; 'subject:API': 0.16; 'thoughts?': 0.16; 'wrote:': 0.17; 'fix': 0.17; 'byte': 0.17; 'pointer': 0.17; 'operations.': 0.22; 'absolute': 0.23; "i've": 0.23; 'seems': 0.23; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'interface': 0.27; 'header:X-Complaints-To:1': 0.28; '>>>>': 0.29; 'arithmetic': 0.29; 'obscure': 0.29; 'position.': 0.30; 'basic': 0.30; 'file': 0.32; 'from:addr:yahoo.co.uk': 0.32; 'legacy': 0.33; 'rid': 0.33; 'to:addr:python-list': 0.33; 'replaced': 0.35; 'received:org': 0.36; 'but': 0.36; 'wanted': 0.36; 'should': 0.36; 'two': 0.37; 'uses': 0.37; 'being': 0.37; 'subject:: ': 0.38; 'mark': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'easily': 0.39; 'called': 0.39; 'header:Received:5': 0.40; 'address': 0.60; "you've": 0.61; 'more': 0.63; 'removal': 0.65; 'received:2': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: python file API Date: Tue, 25 Sep 2012 00:12:30 +0100 References: <0ec1fe2e-890c-4e25-8047-4cb8bee0aa95@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-2-100-238-176.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:15.0) Gecko/20120907 Thunderbird/15.0.1 In-Reply-To: <0ec1fe2e-890c-4e25-8047-4cb8bee0aa95@googlegroups.com> X-Antivirus: avast! (VPS 120924-0, 24/09/2012), Outbound message X-Antivirus-Status: Clean 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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1348528306 news.xs4all.nl 6844 [2001:888:2000:d::a6]:41109 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:29955 On 24/09/2012 22:35, zipher wrote: > For some time now, I've wanted to suggest a better abstraction for the type in Python. It currently uses an antiquated C-style interface for moving around in a file, with methods like tell() and seek(). But after attributes were introduced to Python, it seems it should be re-addressed. > > Let file-type have an attribute .pos for position. Now you can get rid of the seek() and tell() methods and manipulate the file pointer more easily with standard arithmetic operations. > >>>> file.pos = x0ae1 #move file pointer to an absolute address >>>> file.pos +=1 #increment the file pointer one byte >>>> curr_pos = file.pos #read current file pointer > > You've now simplified the API by the removal of two obscure legacy methods and replaced them with a more basic one called "position". > > Thoughts? > > markj > This strikes me as being a case of if it ain't broke don't fix it. -- Cheers. Mark Lawrence.