[Python-Dev] Proof of the pudding: str.partition()
shane at hathawaymix.org
Wed Aug 31 07:29:11 CEST 2005
Terry Reedy wrote:
> "Shane Hathaway" <shane at hathawaymix.org> wrote in message
> news:4314E51B.1050507 at hathawaymix.org...
>>You can do both: make partition() return a sequence with attributes,
>>similar to os.stat(). However, I would call the attributes "before",
>>"sep", and "after".
> One could see that as a special-case back-compatibility kludge that maybe
> should disappear in 3.0. My impression is that the attributes were added
> precisely because unpacking several related attributes into several
> disconnected vars was found to be often awkward. The sequencing is
> arbitrary and one often needs less that all attributes.
Good point. Unlike os.stat(), it's very easy to remember the order of
the return values from partition().
I'll add my +1 vote for part() and +0.9 for partition().
As for the regex version of partition(), I wonder if a little cleanup
effort is in order so that new regex features don't have to be added in
two places. I suggest a builtin for compiling regular expressions,
perhaps called "regex". It would be easier to use the builtin than to
import the re module, so there would no longer be a reason for the re
module to have functions that duplicate the regular expression methods.
More information about the Python-Dev