In article <hjklfd$ll...@foggy.unx.sas.com>, "Tim Arnold" <tim.arn...@sas.com> wrote:
> also, partition works though it returns a tuple instead of a list. > >>> s = 'hello world' > >>> s.partition(' ') > ('hello', ' ', 'world') I've never used partition() before; my first thought on reading the above was, "That's weird, it should be returning a list". Then I went and looked at the docs. Given the description (returns specifically a 3-tuple), I guess a tuple makes sense, but now I'm wondering what the use case was for this method when it was invented? Having a variant of split() which either leaves the delimiter on the end of each word, or returns a list of alternating [word, delimiter, word, delimiter, word] seems logical and orthogonal. In fact, partition() is really just the hypothetical whitespace-preserving variant of split(), with maxsplit=1, except that it returns a tuple instead of a list. So, what was the original problem partition() was trying to solve? -- http://mail.python.org/mailman/listinfo/python-list