strip() using strings instead of chars

Christoph Zwerschke cito at
Sat Jul 12 17:09:15 CEST 2008

Duncan Booth schrieb:
>> if url.startswith('http://'):
>>      url = url[7:]
> If I came across this code I'd want to know why they weren't using 
> urlparse.urlsplit()...

Right, such code can have a smell since in the case of urls, file names, 
config options etc. there are specialized functions available. But I'm 
not sure whether the need for removing string prefix/suffixes in general 
is really so rare that we shouldn't worry to offer a simpler solution.

-- Christoph

More information about the Python-list mailing list