Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed5.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; 'python.': 0.02; 'python,': 0.02; 'attribute': 0.05; 'method.': 0.05; 'attributes': 0.07; 'parameter': 0.07; 'subject:file': 0.07; 'abstraction': 0.09; 'sep': 0.09; 'slices': 0.09; 'subject:python': 0.11; 'suggest': 0.11; '(like': 0.15; 'file,': 0.15; '24,': 0.16; 'adam': 0.16; 'attributes,': 0.16; 'descriptor.': 0.16; 'end-of-file': 0.16; 'list)': 0.16; 'subject:API': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'byte': 0.17; 'pointer': 0.17; '>>>': 0.18; 'operations.': 0.22; 'absolute': 0.23; 'to:2**1': 0.23; "i've": 0.23; 'seems': 0.23; 'second': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; 'interface': 0.27; '>>>>': 0.29; 'arithmetic': 0.29; 'optional': 0.29; "we're": 0.30; 'position.': 0.30; 'relative': 0.30; 'file': 0.32; 'could': 0.32; 'rid': 0.33; 'to:addr:python-list': 0.33; 'done': 0.34; 'pm,': 0.35; 'but': 0.36; 'wanted': 0.36; 'should': 0.36; 'uses': 0.37; 'subject:: ': 0.38; 'mark': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'easily': 0.39; 'received:192.168': 0.40; 'address': 0.60; 'back': 0.62; 'more': 0.63; 'header:Reply-To:1': 0.68; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; 'goals': 0.78; 'to:name:python': 0.84; 'angel': 0.93 Date: Mon, 24 Sep 2012 18:36:00 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: Mark Adam , PYTHON Subject: Re: python file API References: <0ec1fe2e-890c-4e25-8047-4cb8bee0aa95@googlegroups.com> <5060D55C.3000407@davea.name> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:52Zce5N35OAKssFtbwsuA76Crc8isFaj0+lK32PCKFf mc8gzMiM+WYiVYlGFpZ8tgG00SzUP7dW40MCds9M8tDcX1Nj8w z4nxVA2qvvZOQExunEPXd3W1KIqj4ucmcNGyHdbRjpSKU/HOZs wVVqaGbzddlLq1BeRFHQQhdISFDa+hA2YvRpBwAoPMbbfKZGyl XDrnFRy8t66lrEKoxrRWQ2r4VKiLwXX2YEZTdbGL7vkAugoZFa FwN30jMsEIg1/CmWZZW4LuSv8SfjzXxpzY9+IYryZhxFEZ5L1G 3KLQEdWa1KzROjIbyMoyQp99ahv9YWRnYiGDXClcu/JG1BM1Q= = X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: d@davea.name 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: 33 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1348526183 news.xs4all.nl 6844 [2001:888:2000:d::a6]:36978 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:29947 (forwarding to the list) On 09/24/2012 06:23 PM, Mark Adam wrote: > On Mon, Sep 24, 2012 at 4:49 PM, Dave Angel wrote: >> On 09/24/2012 05:35 PM, 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 > >> 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. > > As size is an oft-useful construct, let it (like .name) be part of the > descriptor. Then > >>>> file.pos = file.size - 80 #80 chars from end-of-file > > (Or, one could make slices part of the API...) > > mark > Well, if one of the goals was to reduce the number of attributes, we're now back to the original number of them. -- DaveA