Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:bug': 0.04; '3.2': 0.05; 'subject:Python': 0.06; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'received:gator410.hostgator.com': 0.09; 'splitting': 0.09; 'str': 0.09; '~ethan~': 0.09; 'api': 0.11; 'binary': 0.14; 'subject:file': 0.14; 'wrote:': 0.14; '3.2,': 0.16; 'received:72.11': 0.16; 'received:72.11.125': 0.16; 'received:72.11.125.166': 0.16; 'traceback': 0.16; '(most': 0.16; 'cc:addr:python-list': 0.17; 'bytes': 0.19; 'header:In-Reply- To:1': 0.21; 'cc:2**0': 0.22; 'cc:no real name:2**0': 0.23; 'trying': 0.23; 'last):': 0.23; 'vs.': 0.23; "doesn't": 0.25; 'demonstrate': 0.26; 'object': 0.26; 'thanks': 0.28; 'mode': 0.29; 'unable': 0.30; 'cc:addr:python.org': 0.30; 'typeerror:': 0.30; 'skip:b 30': 0.31; 'seem': 0.32; 'file': 0.34; 'header:User- Agent:1': 0.35; '"",': 0.35; 'using': 0.35; 'issue': 0.37; 'two': 0.37; 'subject:: ': 0.38; 'under': 0.40; 'read,': 0.40; 'below.': 0.65; 'received:websitewelcome.com': 0.67; 'received:69.93': 0.67; 'subject:? ': 0.67; 'email addr:hotmail.com': 0.72; 'subject:line': 0.73; 'succeed': 0.73; '2.7.1': 0.84; 'respectively': 0.84; 'to:addr:hotmail.com': 0.90 Date: Wed, 25 May 2011 16:58:55 -0700 From: Ethan Furman User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: "tkpmep@hotmail.com" Subject: Re: Python 3.2 bug? Reading the last line of a file References: <3d81e2a0-6c86-4f12-a1c4-ce4c736172b6@y31g2000vbp.googlegroups.com> <4DDD5FD2.8040607@mrabarnett.plus.com> <55262a36-ca53-48dd-b563-1847f9442bae@dn9g2000vbb.googlegroups.com> In-Reply-To: <55262a36-ca53-48dd-b563-1847f9442bae@dn9g2000vbb.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator410.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: mail.admailinc.com ([192.168.10.136]) [72.11.125.166]:2111 X-Source-Auth: ethan+stoneleaf.us X-Email-Count: 1 X-Source-Cap: dG9idWs7dG9idWs7Z2F0b3I0MTAuaG9zdGdhdG9yLmNvbQ== Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 21 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1306367183 news.xs4all.nl 49179 [::ffff:82.94.164.166]:60249 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:6277 tkpmep@hotmail.com wrote: > Thanks for the guidance - it was indeed an issue with reading in > binary vs. text., and I do now succeed in reading the last line, > except that I now seem unable to split it, as I demonstrate below. > Here's what I get when I read the last line in text mode using 2.7.1 > and in binary mode using 3.2 respectively under IDLE: > > 3.2 > b'Name\t31/12/2009\t0\t0\t0\r\n' > > under 3.2, with its binary read, I get >--> x.split('\t') > Traceback (most recent call last): > File "", line 1, in > x.split('\t') > TypeError: Type str doesn't support the buffer API You are trying to split a bytes object with a str object -- the two are not compatible. Try splitting with the bytes object b'\t'. ~Ethan~