python equiv of perl's split?

pete-temp-12-29-2002 at kazmier.com pete-temp-12-29-2002 at kazmier.com
Mon Jan 13 09:24:39 EST 2003


Just wondering what the 'best' way of emulating perl's split() method
when used in the following manner:

     split /(:)/

Basically, split the string using a colon as the separator.  NOTE: the
parens indicate that the split function should *include* the colons in
the returned list.  Thus, given the string:

     test:one:two:three

The following array (list) is returned:

     test
     :
     one
     :
     two
     :
     three

What would be the easiest way to emulate this in Python?

Thanks,
Pete





More information about the Python-list mailing list