Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #72762
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <fomcl@yahoo.com> |
| 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:Python': 0.06; "'',": 0.07; 'removes': 0.07; 'string': 0.09; 'character,': 0.09; 'so?': 0.09; 'trailing': 0.09; 'python': 0.11; 'invalid.': 0.16; 'line)': 0.16; 'newline,': 0.16; 'newlines': 0.16; 'perhaps:': 0.16; 'subject:Unicode': 0.16; 'textfile': 0.16; 'index': 0.16; 'thursday,': 0.16; 'wrote:': 0.18; 'thu,': 0.19; '>>>': 0.22; 'input': 0.22; 'tend': 0.24; 'unicode': 0.24; 'paul': 0.24; 'header:In-Reply-To:1': 0.27; 'to:2**1': 0.27; '"",': 0.31; 'end,': 0.31; 'perl': 0.31; 'writes:': 0.31; '-----': 0.33; 'header:Received:9': 0.33; 'there': 0.35; 'really': 0.36; 'ryan': 0.36; 'doing': 0.36; 'subject:?': 0.36; 'to:addr:python-list': 0.38; 'files': 0.38; 'pm,': 0.38; 'subject:': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'ian': 0.60; 'removing': 0.60; 'worry': 0.60; 're:': 0.63; 'relatively': 0.65; 'to:addr:gmail.com': 0.65; 'header:Reply-To:1': 0.67; 'line,': 0.68; 'captures': 0.84; 'subject:you': 0.87 |
| X-Yahoo-Newman-Property | ymail-4 |
| X-Yahoo-Newman-Id | 828443.52489.bm@omp1095.mail.gq1.yahoo.com |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1402000445; bh=RrNk6SG+4+U1Qs82GygyZjfusOFAjpoPWgoHPkBQhYU=; h=References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=z6y9UIOiPUbDdCkIMaHULj/m5hAPM01ApCgUSTyX0R2Z2MZ0fLAgUdW+3JVVHjZOePu5zLIF2G4Jy7IJhanrRchOt0/3f9M5Qyjk9OEzzUTCdZIh0UuzW6mgiZx7o7yCeFMiuEsukfYNbcvcFoPKP1DtyhNkHIc1ykK+eR90csE= |
| X-YMail-OSG | kVvmAHUVM1mKM_v1exM6GPg2BY.NsuIQ5Xfor6TmEpoyb48 7IuD3KqT9d5wP4sZRCrTZIym98bV0f7iBVxvSxUeTzn0Pi9oYNX5NFd5RoMC plBWkMpss3XMXLkaeOsc7gFyhzci8m6BCR5b3riJJNUjXdiw5rS0pABZFVGm Hb165D9q14kHqmrkEkb72fIqcxYUIvQC6ORVvvIRwxr0LIVoi6ZLKecvBVm1 wBcwazUrNElJ902xTuaqbtzUH0uV5YlEsedm68JLTZKkKRs3UYXa3HM6KSk8 5YvP5S00Vrz8ykf3YngeKGvT3dV1uaID3ceaI5DIJLkEZ5tW9l_EAWGkGGOU eXs47fsH2W77lsvBNvMAGUr9g0Ok7lGovuumnJF68rOiI0i7ZubPG9r2ZpRT 1HC2avEl0wIdf3zwjXajDYv9KfsLy8vcJPEReKh50POCgyi8K.iEoaWd64_n c97E7seHYZuc01amSUCwJ1vsvQfqWn9DM3SqBoV7n7qem6ejl16hi9jEoxSr d4kBMtTys8sjE0uIbNXmRq5tiSyZ2PecprONsvTg4qf0WsDCCNjMGa7zo.g- - |
| X-Rocket-MIMEInfo | 002.001, CgoKCgoKLS0tLS0gT3JpZ2luYWwgTWVzc2FnZSAtLS0tLQo.IEZyb206IElhbiBLZWxseSA8aWFuLmcua2VsbHlAZ21haWwuY29tPgo.IFRvOiBQeXRob24gPHB5dGhvbi1saXN0QHB5dGhvbi5vcmc.Cj4gQ2M6IAo.IFNlbnQ6IFRodXJzZGF5LCBKdW5lIDUsIDIwMTQgMTA6MTggUE0KPiBTdWJqZWN0OiBSZTogVW5pY29kZSBhbmQgUHl0aG9uIC0gaG93IG9mdGVuIGRvIHlvdSBpbmRleCBzdHJpbmdzPwo.IAo.IE9uIFRodSwgSnVuIDUsIDIwMTQgYXQgMTo1OCBQTSwgUGF1bCBSdWJpbiA8bm8uZW1haWxAbm8BMAEBAQE- |
| X-Mailer | YahooMailWebService/0.8.190.668 |
| References | <mailman.10656.1401842403.18130.python-list@python.org> <lmq4mu$8nv$1@news.albasani.net> <7xr433z0g3.fsf@ruckus.brouhaha.com> <lmqdn8$scl$1@news.albasani.net> <mailman.10759.1401998071.18130.python-list@python.org> <7xioof9li6.fsf@ruckus.brouhaha.com> <CALwzidm1mg6HunTrBmpcoRgePd=5Aa4=QQ-yEJVB_CAH5ZY+Fw@mail.gmail.com> |
| Date | Thu, 5 Jun 2014 13:34:05 -0700 (PDT) |
| From | Albert-Jan Roskam <fomcl@yahoo.com> |
| Subject | Re: Unicode and Python - how often do you index strings? |
| To | Ian Kelly <ian.g.kelly@gmail.com>, Python <python-list@python.org> |
| In-Reply-To | <CALwzidm1mg6HunTrBmpcoRgePd=5Aa4=QQ-yEJVB_CAH5ZY+Fw@mail.gmail.com> |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=iso-8859-1 |
| Content-Transfer-Encoding | quoted-printable |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| Reply-To | Albert-Jan Roskam <fomcl@yahoo.com> |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.10767.1402000635.18130.python-list@python.org> (permalink) |
| Lines | 18 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1402000635 news.xs4all.nl 2938 [2001:888:2000:d::a6]:42260 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:72762 |
Show key headers only | View raw
----- Original Message -----
> From: Ian Kelly <ian.g.kelly@gmail.com>
> To: Python <python-list@python.org>
> Cc:
> Sent: Thursday, June 5, 2014 10:18 PM
> Subject: Re: Unicode and Python - how often do you index strings?
>
> On Thu, Jun 5, 2014 at 1:58 PM, Paul Rubin <no.email@nospam.invalid>
> wrote:
>> Ryan Hiebert <ryan@ryanhiebert.com> writes:
>>> 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?
>>
>> rstrip removes all the newlines off the end, whether there are zero or
>> multiple. In perl the difference is chomp vs chop. line=line[:-1]
>> removes one character, that might or might not be a newline.
>
> Given the description that the input string is "a textfile line", if
> it has multiple newlines then it's invalid.
>
> Personally I tend toward rstrip('\r\n') so that I don't have
> to worry
> about files with alternative line terminators.
I tend to use: s.rstrip(os.linesep)
> If you want to be really picky about removing exactly one line
> terminator, then this captures all the relatively modern variations:
> re.sub('\r?\n$|\n?\r$', line, '', count=1)
or perhaps: re.sub("[^ \S]+$", "", line)
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Unicode and Python - how often do you index strings? Chris Angelico <rosuav@gmail.com> - 2014-06-04 10:39 +1000
Re: Unicode and Python - how often do you index strings? Roy Smith <roy@panix.com> - 2014-06-03 21:18 -0400
Re: Unicode and Python - how often do you index strings? Chris Angelico <rosuav@gmail.com> - 2014-06-04 12:13 +1000
Re: Unicode and Python - how often do you index strings? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-06-04 18:48 +1200
Re: Unicode and Python - how often do you index strings? alister <alister.nospam.ware@ntlworld.com> - 2014-06-04 10:57 +0000
Re: Unicode and Python - how often do you index strings? alister <alister.nospam.ware@ntlworld.com> - 2014-06-04 10:50 +0000
Re: Unicode and Python - how often do you index strings? Rustom Mody <rustompmody@gmail.com> - 2014-06-04 05:52 -0700
Re: Unicode and Python - how often do you index strings? alister <alister.nospam.ware@ntlworld.com> - 2014-06-04 13:36 +0000
Re: Unicode and Python - how often do you index strings? wxjmfauth@gmail.com - 2014-06-03 23:50 -0700
Re: Unicode and Python - how often do you index strings? Michael Torrie <torriem@gmail.com> - 2014-06-04 08:50 -0600
Re: Unicode and Python - how often do you index strings? wxjmfauth@gmail.com - 2014-06-05 00:06 -0700
Re: Unicode and Python - how often do you index strings? Marko Rauhamaa <marko@pacujo.net> - 2014-06-05 10:20 +0300
Re: Unicode and Python - how often do you index strings? alister <alister.nospam.ware@ntlworld.com> - 2014-06-05 15:39 +0000
Re: Unicode and Python - how often do you index strings? Mark H Harris <harrismh777@gmail.com> - 2014-06-05 10:57 -0500
Re: Unicode and Python - how often do you index strings? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-06-05 18:15 +0100
Re: Unicode and Python - how often do you index strings? alister <alister.nospam.ware@ntlworld.com> - 2014-06-05 17:33 +0000
Re: Unicode and Python - how often do you index strings? Joshua Landau <joshua@landau.ws> - 2014-06-05 18:18 +0100
Re: Unicode and Python Rustom Mody <rustompmody@gmail.com> - 2014-06-04 21:25 -0700
Re: Unicode and Python wxjmfauth@gmail.com - 2014-06-05 00:23 -0700
Re: Unicode and Python - how often do you index strings? Johannes Bauer <dfnsonfsduifb@gmx.de> - 2014-06-05 18:09 +0200
Re: Unicode and Python - how often do you index strings? Paul Rubin <no.email@nospam.invalid> - 2014-06-05 11:16 -0700
Re: Unicode and Python - how often do you index strings? Johannes Bauer <dfnsonfsduifb@gmx.de> - 2014-06-05 20:42 +0200
Re: Unicode and Python - how often do you index strings? Ryan Hiebert <ryan@ryanhiebert.com> - 2014-06-05 13:52 -0500
Re: Unicode and Python - how often do you index strings? Paul Rubin <no.email@nospam.invalid> - 2014-06-05 12:58 -0700
Re: Unicode and Python - how often do you index strings? Ian Kelly <ian.g.kelly@gmail.com> - 2014-06-05 14:18 -0600
Re: Unicode and Python - how often do you index strings? Johannes Bauer <dfnsonfsduifb@gmx.de> - 2014-06-06 10:47 +0200
Re: Unicode and Python - how often do you index strings? Tim Chase <python.list@tim.thechases.com> - 2014-06-06 05:37 -0500
Re: Unicode and Python - how often do you index strings? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-06-06 11:52 +0000
Re: Unicode and Python - how often do you index strings? Albert-Jan Roskam <fomcl@yahoo.com> - 2014-06-05 13:34 -0700
Re: Unicode and Python - how often do you index strings? Roy Smith <roy@panix.com> - 2014-06-05 17:00 -0400
Re: Unicode and Python - how often do you index strings? Rustom Mody <rustompmody@gmail.com> - 2014-06-05 15:24 -0700
Re: Unicode and Python - how often do you index strings? Ned Deily <nad@acm.org> - 2014-06-05 15:57 -0700
Re: Unicode and Python - how often do you index strings? Roy Smith <roy@panix.com> - 2014-06-05 20:10 -0400
Re: Unicode and Python - how often do you index strings? Ned Deily <nad@acm.org> - 2014-06-05 17:43 -0700
Re: Unicode and Python - how often do you index strings? Grant Edwards <invalid@invalid.invalid> - 2014-06-06 14:20 +0000
Re: Unicode and Python - how often do you index strings? Ian Kelly <ian.g.kelly@gmail.com> - 2014-06-05 18:05 -0600
Re: Unicode and Python - how often do you index strings? Johannes Bauer <dfnsonfsduifb@gmx.de> - 2014-06-06 10:42 +0200
Re: Unicode and Python - how often do you index strings? Larry Hudson <orgnut@yahoo.com> - 2014-06-06 20:24 -0700
Re: Unicode and Python - how often do you index strings? Chris Angelico <rosuav@gmail.com> - 2014-06-06 05:59 +1000
Re: Unicode and Python - how often do you index strings? Ryan Hiebert <ryan@ryanhiebert.com> - 2014-06-05 15:05 -0500
csiph-web