like a "for loop" for a string

Wojtek Walczak gminick at bzt.bzt
Sun Aug 17 19:45:47 EDT 2008


On Sun, 17 Aug 2008 12:07:45 -0700 (PDT), bearophileHUGS at lycos.com wrote:

> I'm waiting for a str.xsplit still :-)
> If I write and submit a C implementation of xsplit how many chances do
> I have to see it included into Python? :-)

Got no idea, but it might be a nice try. It should be a quite good memory
saver for very large strings. While browsing the implementation of
split method I discovered something I didn't really realise before.
While calling split method without arguments it treats all four signs:
' ', '\n', '\r' and '\t' as a whitespace, so it's not the same as
str.split(' '). Moreover, specifying maxsplit argument whenever possible
seems to be a good practice. Anyway, go ahead with that xsplit thing :-)

-- 
Regards,
Wojtek Walczak,
http://www.stud.umk.pl/~wojtekwa/



More information about the Python-list mailing list