Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1a.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'anyway.': 0.05; 'subject:Python': 0.06; 'additionally': 0.09; 'so?': 0.09; 'trailing': 0.09; 'cc:addr:python-list': 0.11; '>>': 0.16; 'from:addr:ryan': 0.16; 'iterable,': 0.16; 'newline,': 0.16; 'newlines': 0.16; 'received:74.125.82.46': 0.16; 'subject:Unicode': 0.16; 'textfile': 0.16; 'truncates': 0.16; 'wrote:': 0.18; 'thu,': 0.19; '>>>': 0.22; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; '>>>': 0.24; "shouldn't": 0.24; 'paul': 0.24; 'cc:2**0': 0.24; '>': 0.26; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; "skip:' 10": 0.31; 'that.': 0.31; 'writes:': 0.31; 'file': 0.32; 'fri,': 0.33; 'skip:& 30': 0.33; 'received:74.125.82': 0.34; 'case,': 0.35; 'received:google.com': 0.35; 'ryan': 0.36; 'doing': 0.36; 'subject:?': 0.36; 'skip:& 10': 0.38; 'issue': 0.38; 'pm,': 0.38; 'received:74.125': 0.39; 'how': 0.40; 'removing': 0.60; 'different': 0.65; 'to:addr:gmail.com': 0.65; 'guaranteed': 0.75; 'subject:you': 0.87 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=Pe8NE27Wb3UcrXPSHgPws1N7+jM5Jhy5h4/CigHtvOo=; b=OQzcOX1/OXHCkjpNRdIQohIcgQ7k73uPXJQcCZ8GP5I48mHO4NBggT0s7DtPRDKEEH avpZ5tYnHAQOruzRZemCnIUonCalVgHx/Qe+aXEouRVqAca+1BP95PwO/AU8zeSuPW8n naCALdt/Q2UWZuikvo+eJ+BksP+XNvYHlZO54erslmVAckGykxktHg28nFrTr/IC9Af2 ABgfMlacPFXpkEZrRDLJpALtjMKjkziUEYNQxiZEdgmxn+XyXX0HwOIA06r7L8HnAYFU 84mED15vfEFk0o7Vapky8OuAuEAWeYx+nwW3h/FbvHWufbN6dvH2AgCUjhL3L0e6O+g7 nGzA== X-Gm-Message-State: ALoCoQk1ufR16OjACpH8zGjv022dFaewaKl4HRY73uiunX4YqYqOOqQGm0t4yOeAgGW8f3NlVfPm MIME-Version: 1.0 X-Received: by 10.194.6.2 with SMTP id w2mr41151wjw.6.1401998745478; Thu, 05 Jun 2014 13:05:45 -0700 (PDT) X-Originating-IP: [98.172.7.178] In-Reply-To: References: <7xr433z0g3.fsf@ruckus.brouhaha.com> Date: Thu, 5 Jun 2014 15:05:45 -0500 Subject: Re: Unicode and Python - how often do you index strings? From: Ryan Hiebert To: Chris Angelico Content-Type: multipart/alternative; boundary=047d7b5d2e2033967604fb1c4502 Cc: "python-list@python.org" 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: 82 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1401999232 news.xs4all.nl 2941 [2001:888:2000:d::a6]:48439 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:72754 --047d7b5d2e2033967604fb1c4502 Content-Type: text/plain; charset=UTF-8 On Thu, Jun 5, 2014 at 2:59 PM, Chris Angelico wrote: > On Fri, Jun 6, 2014 at 4:52 AM, Ryan Hiebert wrote: > > 2014-06-05 13:42 GMT-05:00 Johannes Bauer : > > > >> On 05.06.2014 20:16, Paul Rubin wrote: > >> > Johannes Bauer writes: > >> >> line = line[:-1] > >> >> Which truncates the trailing "\n" of a textfile line. > >> > > >> > use line.rstrip() for that. > >> > >> rstrip has different functionality than what I'm doing. > > > > > > How so? I was using line=line[:-1] for removing the trailing newline, and > > just replaced it with rstrip('\n'). What are you doing differently? > > >>> line = "Hello,\nworld!\n\n" > >>> line[:-1] > 'Hello,\nworld!\n' > >>> line.rstrip('\n') > 'Hello,\nworld!' > > If it's guaranteed to end with exactly one newline, then and only then > will they be identical. > > OK, that's not an issue for my case, and additionally I'm using the open(_, 'U') file iterable, so I shouldn't see multiple trailing newlines anyway. --047d7b5d2e2033967604fb1c4502 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On T= hu, Jun 5, 2014 at 2:59 PM, Chris Angelico <rosuav@gmail.com>= wrote:
On F= ri, Jun 6, 2014 at 4:52 AM, Ryan Hiebert <ryan@ryanhiebert.com> wrote:
> 2014-06-05 13:42 GMT-05:00 Johannes Bauer <dfnsonfsduifb@gmx.de>:
>
>> On 05.06.2014 20:16, Paul Rubin wrote:
>> > Johannes Bauer <df= nsonfsduifb@gmx.de> writes:
>> >> line =3D line[:-1]
>> >> Which truncates the trailing "\n" of a textfile= line.
>> >
>> > use line.rstrip() for that.
>>
>> rstrip has different functionality than what I'm doing.
>
>
> How so? I was using line=3Dline[:-1] for removing the trailing newline= , and
> just replaced it with rstrip('\n'). What are you doing differe= ntly?

>>> line =3D "Hello,\nworld!\n\n"
>>> line[:-1]
'Hello,\nworld!\n'
>>> line.rstrip('\n')
'Hello,\nworld!'

If it's guaranteed to end with exactly one newline, then and only then<= br> will they be identical.
<= br>
=C2=A0OK, that's not an issue for my= case, and additionally I'm using the open(_, 'U') file iterabl= e, so I shouldn't see multiple trailing newlines anyway.

--047d7b5d2e2033967604fb1c4502--