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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:file': 0.07; 'received:mail-vc0-f174.google.com': 0.09; 'sep': 0.09; 'subject:python': 0.11; 'language': 0.14; 'result.': 0.15; '24,': 0.16; 'immutable,': 0.16; 'similarly,': 0.16; 'subject:API': 0.16; 'subtraction': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'bytes': 0.17; 'integer': 0.17; 'pointer': 0.17; 'specifies': 0.17; 'saying': 0.18; 'equivalent': 0.20; 'properties': 0.24; 'header:In-Reply- To:1': 0.25; 'object,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'chris': 0.28; 'received:209.85.220.174': 0.29; 'file': 0.32; 'could': 0.32; 'int': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'pm,': 0.35; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'should': 0.36; 'does': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'to:addr:python.org': 0.39; 'skip:" 10': 0.40; 'header:Received:5': 0.40; 'more': 0.63; '100': 0.78; 'presumably': 0.84; 'to:name:python': 0.84 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:x-gm-message-state; bh=7kJJhIHtn8yNt9Q2FakiVfuXqxLlswinaV05ZvNMyXs=; b=Uj0sGmcACwBDnq2kdYIDeGc/xlveAlSEdmRor/tYlEsDECMCfISHZNPRK/JxUlxMAm JPCVfrv6UeD3xTCofR3mETbrpXIY+GLRkoh7WQQVUdufyM1AAgQoJ2ZGQkH8GWE0oe3X 09DVq8tzl3ibbQoCYRYXl3cSalThpwKL425Od1Fmw8l4go8EMr+hGEICfBL8D63+VwB6 E8/2M4L+q2F9JF7Uyah0vAJ4HiRLGaKYEumLPVL7RPX8ZtPdkhbfDk5ka4XVgBjCmzQx 6CVmRLKMwN11dybOh7J16/2iX77M8CRk11b5jzCkyoDWOYbYX5wBVHPiA0W7OID4XOcY q7SQ== MIME-Version: 1.0 In-Reply-To: References: <0ec1fe2e-890c-4e25-8047-4cb8bee0aa95@googlegroups.com> <5060D55C.3000407@davea.name> From: Chris Kaynor Date: Mon, 24 Sep 2012 16:14:37 -0700 Subject: Re: python file API To: Python Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQl0+xgyPla1hx5yLax9sThGbJ06Wma7+UNOOaex8qTVy6o8R1eLCRDnNW9joZbT9WjHVDMT 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: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1348528500 news.xs4all.nl 6862 [2001:888:2000:d::a6]:45302 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:29957 On Mon, Sep 24, 2012 at 3:37 PM, Ian Kelly wrote: > On Mon, Sep 24, 2012 at 4:14 PM, Chris Angelico wrote: >> file.pos = 42 # Okay, you're at position 42 >> file.pos -= 10 # That should put you at position 32 >> foo = file.pos # Presumably foo is the integer 32 >> file.pos -= 100 # What should this do? > > Since ints are immutable, the language specifies that it should be the > equivalent of "file.pos = file.pos - 100", so it should set the file > pointer to 68 bytes before EOF. There is no reason that it has to be an int object, however. It could well return a "FilePosition" object which does not allow subtraction to produce a negative result. Not saying its a good idea... Similarly, it could be a more complex object with properties on it to determine whether to seek from beginning or end.