I use Python's str.partition
in my code in three ways:
before, __, after = string.partition(sep)
before = string.partition(sep)[0]
after = string.partition(sep)[2]
While I use str.partition
frequently, I've always wondered why it returns the separator. The first line surely would benefit from it not returning the separator, and in my opinion, also the third line would become more intuitive.
While I acknowledge that one can re-build the string with
"".join(string.partition(sep))
I do not see any use case for this.
So, what is the rationale of the inclusion of the separator in the returned tuple?