On Mon, Oct 31, 2011 at 6:32 PM, Patrick Maupin <pmau...@gmail.com> wrote: > On Oct 31, 5:52 pm, Ian Kelly <ian.g.ke...@gmail.com> wrote: >> For instance, split() will split on vertical tab, >> which is not one of the characters the OP wanted. > > That's just the default behavior. You can explicitly specify the > separator to split on. But it's probably more efficient to just use > translate with deletechars.
As I understood it, the point of using the default behavior was to merge whitespace, which cannot be done when the separator is explicitly specified. For example: >>> " ".split() [] >>> " ".split(" ") ['', '', '', '', '', ''] It is easy to check that the first is empty. The second is a bit more annoying and is O(n). Your point about deletechars is good, though, definitely better than a regular expression. -- http://mail.python.org/mailman/listinfo/python-list