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


Groups > comp.lang.python > #22045 > unrolled thread

Odd strip behavior

Started byRodrick Brown <rodrick.brown@gmail.com>
First post2012-03-22 15:48 -0400
Last post2012-03-22 20:56 +0100
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  Odd strip behavior Rodrick Brown <rodrick.brown@gmail.com> - 2012-03-22 15:48 -0400
    Re: Odd strip behavior Kiuhnm <kiuhnm03.4t.yahoo.it> - 2012-03-22 20:56 +0100

#22045 — Odd strip behavior

FromRodrick Brown <rodrick.brown@gmail.com>
Date2012-03-22 15:48 -0400
SubjectOdd strip behavior
Message-ID<mailman.903.1332445730.3037.python-list@python.org>
#!/usr/bin/python
 
def main():
 
    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 ?
Sent from my iPhone

[toc] | [next] | [standalone]


#22048

FromKiuhnm <kiuhnm03.4t.yahoo.it>
Date2012-03-22 20:56 +0100
Message-ID<4f6b83e3$0$1389$4fafbaef@reader1.news.tin.it>
In reply to#22045
On 3/22/2012 20:48, Rodrick Brown wrote:
> #!/usr/bin/python
>
> def main():
>
>      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 ?

Because it's not a leading or trailing character.

Kiuhnm

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web