[Python-Dev] Python 2.5 Schedule
Giovanni Bajo
rasky at develer.com
Sat Mar 18 19:15:10 CET 2006
Raymond Hettinger <python at rcn.com> wrote:
> They include [...] the str.partition function,
Where is the current version of this patch?
After reharsing the archives, I have an additional suggestion which I didn't
find already mentioned in the discussion. What about:
str.partition() -> (left, right or None)
str.rparition() -> (left or None, right)
which means:
"foo:bar".partition(":") -> ("foo", "bar")
"foo:bar".rpartition(":") -> ("foo", "bar")
"foo:".partition(":") -> ("foo", "")
"foo:".rpartition(":") -> ("foo", "")
":foo".partition(":") -> ("", "foo")
":foo".rpartition(":") -> ("", "foo")
"foo".partition(":") -> ("foo", None)
"foo".rpartition(":") -> (None, "foo")
Notice that None-checking can be done as a way to know if the separator was
found. I mentally went through the diff here
(http://mail.python.org/pipermail/python-dev/2005-August/055781.html) and
found out that most (all?) the usages of '_' disappears with this semantic.
--
Giovanni Bajo
More information about the Python-Dev
mailing list