A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-August/055853.html below:

[Python-Dev] partition() (was: Remove str.find in 3.0?)

[Python-Dev] partition() (was: Remove str.find in 3.0?)Phillip J. Eby pje at telecommunity.com
Tue Aug 30 20:44:44 CEST 2005
At 02:25 PM 8/30/2005 -0400, Raymond Hettinger wrote:
>That case should be handled with consecutive partitions:
>
># keep everything after the second 'X'
>head, found, s = s.partition('X')
>head, found, s = s.partition('x')

Or:

      s=s.partition('X')[2].partition('X')[2]

which actually suggests a shorter, clearer way to do it:

      s = s.after('X').after('X')

And the corresponding 'before' method, of course, such that if sep in s:

      s.before(sep), sep, s.after(sep) == s.partition(sep)

Technically, these should probably be before_first and after_first, with 
the corresponding before_last and after_last corresponding to rpartition.

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4