string.split and re.split inconsistency

Gordon McMillan gmcm at hypernet.com
Sat Sep 25 09:18:25 EDT 1999


Han-Wen Nienhuys writes:
 
> Is there any particular reason why string.split and re.split tke
> arguments in different order?  I think it is confusing, and would
> prefer to have it fixed (although I realise that a backwards
> compatible fix is hard)
> 
> libre has split(pattern, string) and libstring has split(string,
> sep)

In string split, the string is the "object" and sep is a qualifier. 
In re, the "object" is the pattern. If you compile the pattern, it 
already has a split method (that takes a string). In 1.6, split 
will be a method of string objects. So the confusion will go 
away, just not the way you want. (Your solution would make 
split inconsistent with the other functions in whichever module 
you changed).

- Gordon




More information about the Python-list mailing list