strip() using strings instead of chars
Christoph Zwerschke
cito at online.de
Sat Jul 12 11:09:15 EDT 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