[Tutor] python 3.3 split method confusion

Alan Gauld alan.gauld at btinternet.com
Sat Jan 4 15:25:19 CET 2014


On 04/01/14 14:10, Christian Alexander wrote:

> I am curious to know why the split() method does not output the
> arbitrary delimiter that is passed as an argument?  For example:

Because in most cases you don't want it and would have to strip
it off each element manually after the event.

I suppose they could have had a preserve parameter with a
default value of False for the few cases where you want to
keep it.

But in the majority of cases split is used where we read a line
of input from a data file where the data fields are separated
by some arbitrary character, usually comma, tab or pipe. The
important bit is the data not the separator.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos



More information about the Tutor mailing list