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.

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to