[Tutor] python 3.3 split method confusion

Christian Alexander christian.h.alexander at gmail.com
Sat Jan 4 22:38:29 CET 2014


Thank you for clarifying my inquiry.  I was just unable to find the reason
as to why the built-in excludes the delimiter from the outpu.


On Sat, Jan 4, 2014 at 9:25 AM, Alan Gauld <alan.gauld at btinternet.com>wrote:

> 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
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>



-- 
Regards,

Christian Alexander
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140104/ba723baf/attachment.html>


More information about the Tutor mailing list