Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #22047

RE: Odd strip behavior

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <ramit.prasad@jpmorgan.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'api.': 0.05; 'completeness': 0.05; 'main()': 0.05; 'behavior,': 0.07; 'defaults': 0.07; 'does.': 0.07; 'specifying': 0.07; '__name__': 0.09; 'prefix': 0.09; 'trailing': 0.09; 'message-----': 0.12; 'def': 0.13; 'argument': 0.15; 'to:name:python-list@python.org': 0.15; "'__main__':": 0.16; '2.2.2:': 0.16; '712': 0.16; 'currencies': 0.16; 'disclaimers': 0.16; 'disclaimers,': 0.16; 'from:addr:jpmorgan.com': 0.16; 'main():': 0.16; 'received:155.180': 0.16; 'received:159.53': 0.16; 'received:bankone.net': 0.16; 'received:exchad.jpmchase.net': 0.16; 'received:jpmchase.com': 0.16; 'received:jpmchase.net': 0.16; 'received:svr.bankone.net': 0.16; 'securities,': 0.16; 'spacious': 0.16; 'stripped:': 0.16; 'subject:behavior': 0.16; 'suffix;': 0.16; 'url:disclosures': 0.16; 'url:jpmorgan': 0.16; 'whitespace.': 0.16; '>>>': 0.18; 'header:In-Reply-To:1': 0.22; 'changed': 0.23; 'string': 0.24; 'removed.': 0.24; 'url:mailman': 0.27; 'received:169': 0.28; 'received:169.254': 0.28; 'odd': 0.29; "skip:' 30": 0.29; 'print': 0.29; '22,': 0.30; 'none,': 0.30; 'omitted': 0.30; 'received:155': 0.30; 'received:159': 0.30; 'url:library': 0.31; 'url:listinfo': 0.32; 'version': 0.32; 'values': 0.32; 'accuracy': 0.32; 'familiar': 0.32; 'it.': 0.33; 'skip:# 10': 0.34; 'to:addr:python-list': 0.35; 'phone:': 0.35; 'subject:': 0.35; 'url:python': 0.35; 'skip:p 50': 0.37; 'charset :us-ascii': 0.37; 'listed': 0.38; 'sent:': 0.38; 'characters': 0.39; 'url:org': 0.39; 'from:': 0.40; 'to:addr:python.org': 0.40; 'march': 0.61; 'subject': 0.61; 'offers': 0.62; 'leading': 0.62; 'iphone': 0.68; 'become': 0.69; 'information,': 0.69; 'legal': 0.72; 'url:email': 0.72; 'bank': 0.75; 'sale': 0.75; 'investment': 0.77; 'purchase': 0.78; 'brown': 0.80; 'received:169.254.8': 0.84
X-DKIM OpenDKIM Filter v2.1.3 sz1.jpmchase.com q2MJsjZ7008342
DKIM-Signature v=1; a=rsa-sha256; c=simple/simple; d=jpmorgan.com; s=smtpout; t=1332446086; bh=w8nyQ4pONn4Ob0mUNHZBd28VYlEu1IeDHDmpIHccGwI=; h=From:To:Subject:Date:Message-ID:References:In-Reply-To: Content-Transfer-Encoding:MIME-Version:Content-Type; b=kORXlLQqJXBbI7CocKzlnB9ujQbgrQr/gkoOIn0RNFBhxRXz/S715cPMDITJomXR6 yO3QkuRbnLdz5LAXpGM0UOSd8eV3iDlu4ExQQSsdVOS34fsT9seQTSRE+BzBxf2lLX xVCM9A/HxG8KbD/pbBgXJFd6dML2PECojLH4Zams=
From "Prasad, Ramit" <ramit.prasad@jpmorgan.com>
To "python-list@python.org" <python-list@python.org>
Subject RE: Odd strip behavior
Thread-Topic Odd strip behavior
Thread-Index AQHNCGTToUORfkWu+0Ww1H6LCvJUfZZ2uPkw
Date Thu, 22 Mar 2012 19:54:37 +0000
References <5B2CBFB0-DC2D-47E1-978F-59E47EB3A757@gmail.com>
In-Reply-To <5B2CBFB0-DC2D-47E1-978F-59E47EB3A757@gmail.com>
Accept-Language en-US
Content-Language en-US
X-MS-Has-Attach
X-MS-TNEF-Correlator
x-originating-ip [10.67.79.38]
Content-Transfer-Encoding quoted-printable
MIME-Version 1.0
X-DLP-FWD Yes
Content-Type text/plain; charset="us-ascii"
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.906.1332446094.3037.python-list@python.org> (permalink)
Lines 31
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1332446094 news.xs4all.nl 6922 [2001:888:2000:d::a6]:34635
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:22047

Show key headers only | View raw


>     str1='this is a test'
>     str2='t'
> 
>     print "".join([ c for c in str1 if c not in str2 ])
>     print(str1.strip(str2))
> 
> if __name__ == '__main__':
>     main()
> 
> ./remove_str.py
> his is a es
> his is a tes
> 
> Why wasnt the t removed ?

This is not odd behavior, you just do not understand what
strip does. :)

The behavior is listed on the API. I highly recommend you 
take time to become familiar with it. 


http://docs.python.org/library/stdtypes.html#string-methods
str.strip([chars])
    Return a copy of the string with the leading and trailing characters removed. The chars argument is a string specifying the set of characters to be removed. If omitted or None, the chars argument defaults to removing whitespace. The chars argument is not a prefix or suffix; rather, all combinations of its values are stripped:
    >>>
    >>> '   spacious   '.strip()
    'spacious'
    >>> 'www.example.com'.strip('cmowz.')
    'example'


    Changed in version 2.2.2: Support for the chars argument.

Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--


> -----Original Message-----
> From: python-list-bounces+ramit.prasad=jpmorgan.com@python.org
> [mailto:python-list-bounces+ramit.prasad=jpmorgan.com@python.org] On Behalf
> Of Rodrick Brown
> Sent: Thursday, March 22, 2012 2:49 PM
> To: python-list@python.org
> Subject: Odd strip behavior
> 
> #!/usr/bin/python
> 
> def main():
> 
> Sent from my iPhone
> --
> http://mail.python.org/mailman/listinfo/python-list
This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

RE: Odd strip behavior "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-03-22 19:54 +0000

csiph-web