Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #86358
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ckaynor@zindagigames.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.046 |
| X-Spam-Evidence | '*H*': 0.91; '*S*': 0.00; 'removes': 0.07; 'subject:bug': 0.07; 'get.': 0.09; 'prefix': 0.09; '24,': 0.16; 'backslash': 0.16; 'does,': 0.16; 'guessing': 0.16; 'such,': 0.16; 'wrote:': 0.18; 'seems': 0.21; 'feb': 0.22; '>>>': 0.22; 'email addr:gmail.com>': 0.22; 'to:name:python-list@python.org': 0.22; 'error': 0.23; '>>>': 0.24; 'case.': 0.24; '(see': 0.26; 'possibly': 0.26; 'header:In-Reply-To:1': 0.27; 'correct': 0.29; 'characters': 0.30; 'specified': 0.30; 'message- id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; "skip:' 10": 0.31; 'quite': 0.32; 'url:python': 0.33; 'received:74.125.82': 0.34; 'could': 0.34; 'except': 0.35; 'skip:u 20': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'url:org': 0.36; 'should': 0.36; 'list': 0.37; 'skip:& 10': 0.38; 'url:library': 0.38; 'handle': 0.38; 'whatever': 0.38; 'to:addr:python-list': 0.38; 'issue': 0.38; 'pm,': 0.38; 'expect': 0.39; 'received:74.125': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'remove': 0.60; 'skip:u 10': 0.60; 'url:3': 0.61; 'first': 0.61; 'forward': 0.65; 'believe': 0.68; 'url:4': 0.69; 'manner': 0.72; "'if": 0.84; '2015': 0.84; 'code):': 0.84 |
| 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:from:date :message-id:subject:to:content-type; bh=JFlUc7qWObOGVf3hmu2bc8ugW0G4wRB56rKepkt6res=; b=IqcMiJdfwOnTULa73V8tuSV27Ng+aQaqt291b14SZonVPuYp2kJmZPjT7qJpbiq7/n uN+sMbcG2VIwu8OAw1MgM0R2HXo77jTXSCsp3l3afGA9Gn+i8KtZHXbrdiqjCj2VODpK izjjRTqTNPJrBbhrzTbEbFZcL3TJQHJ5/8h46mYCHVSrXR6+dujSROlHpcLFcVUr14Fo DMjC5IgX0f4+uSOJLafZMSrPP7U9f7D94hd77GhhkaPEWed8ApCSFbq2L3+HXeWy65mz QorHeeIz13E1n6eiFRoxfEj3jV4Iw2BbLpZTiqzTBVKqCWvkNkQHzbluJC+ZGE712j5g BSDw== |
| X-Gm-Message-State | ALoCoQnhD+1GBY1Be4GDIpvzkOtP8aMDeCMF//68QRlLZTUQR7Ll+dfTNiRMHRWRubRw7Hgqrrnl |
| X-Received | by 10.195.12.97 with SMTP id ep1mr583176wjd.134.1424820146832; Tue, 24 Feb 2015 15:22:26 -0800 (PST) |
| MIME-Version | 1.0 |
| In-Reply-To | <3a54074b-2517-472b-9fcc-50348933a959@googlegroups.com> |
| References | <3a54074b-2517-472b-9fcc-50348933a959@googlegroups.com> |
| From | Chris Kaynor <ckaynor@zindagigames.com> |
| Date | Tue, 24 Feb 2015 15:22:06 -0800 |
| Subject | Re: strip bug? |
| To | "python-list@python.org" <python-list@python.org> |
| Content-Type | multipart/alternative; boundary=047d7bfceb40b8997e050fddcacf |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| 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.19155.1424820483.18130.python-list@python.org> (permalink) |
| Lines | 70 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1424820483 news.xs4all.nl 2859 [2001:888:2000:d::a6]:42348 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:86358 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
On Tue, Feb 24, 2015 at 3:05 PM, <baykiwi@gmail.com> wrote:
> >>> 'http://xthunder'.strip('http://')
> 'xthunder'
> >>> 'http://thunder'.strip('http://')
> 'under'
> >>>
>
> I could understand backslash but forward slash?
I believe the issue is that str.strip does not do quite what you are
thinking it does, however your message is very unspecific about what you
expect to get. It seems that you except str.strip to remove a sub-string,
while it actually removes the list of specified characters (see
https://docs.python.org/3.4/library/stdtypes.html?highlight=str.strip#str.strip).
As such, you would get the same result from 'http://thunder'.strip('htp:/')
and 'http://thunder'.strip('/thp:') as from your samples.
To get what I am guessing you want ("xthunder" for the first and "thunder"
for the second), you should use splicing, likely combined with
str.startswith() (untested code):
url = 'http://thunder/
if url.startswith('http://'):
url = url[7:]
else
# Handle case without the prefix in whatever manner is correct for your
case. Possibly continue, possibly error out.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
strip bug? baykiwi@gmail.com - 2015-02-24 15:05 -0800 Re: strip bug? Eduardo <xcesar@gmail.com> - 2015-02-24 15:15 -0800 Re: strip bug? Ian Kelly <ian.g.kelly@gmail.com> - 2015-02-24 16:16 -0700 Re: strip bug? Irmen de Jong <irmen.NOSPAM@xs4all.nl> - 2015-02-25 00:19 +0100 Re: strip bug? Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2015-02-25 00:25 +0100 Re: strip bug? Chris Kaynor <ckaynor@zindagigames.com> - 2015-02-24 15:22 -0800 Re: strip bug? Rustom Mody <rustompmody@gmail.com> - 2015-02-25 03:03 -0800 Re: strip bug? babyG <bintadoma20@yahoo.com> - 2015-02-27 04:18 -0600
csiph-web