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/2006-September/068640.html below:

[Python-Dev] Fwd: Problem withthe API for str.rpartition()

[Python-Dev] Fwd: Problem withthe API for str.rpartition() [Python-Dev] Fwd: Problem withthe API for str.rpartition()Raymond Hettinger rhettinger at ewtllc.com
Tue Sep 5 21:06:03 CEST 2006
Ron Adam wrote:

>I hope this discussion is only about the words used and the
>documentation and not about the actual order of what is received. I
>would expect both the following should be true, and it is the current
>behavior.
>
>     ''.join(s.partition(sep)) -> s
>     ''.join(s.rpartition(sep)) -> s
>
>  
>

Right.  The only thing in question is wording for the documentation. 

The viable options on the table are:
* Leave the current wording and add a clarifying example.
* Switch to left/sep/right and add a clarifying example.

The former tells you which part can still contain a separator and 
suggests how to use the tool when successive partitions are needed.  The 
latter makes the left/right ordering clear and tells you nothing about 
which part can still have the separators in it.  That has some import 
because the use cases for rpartition() all involve strings with multiple 
separators --if there were only one, you would just use partition().

BTW, the last check-in fixed the return value for the sep-not-found 
case, so that now:
   'a'.partition('x') -->  ('a', '', '')
   'a'.rpartition('x') -->  ('', '', 'a')

This was necessary so that looping/recursion would work and so that 
rpartition() acts as a mirror-image of partition().


Raymond





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