Christoph Zwerschke <[EMAIL PROTECTED]> wrote:
> 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, fil
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 avail
Christoph Zwerschke <[EMAIL PROTECTED]> wrote:
> In Python programs, you will quite frequently find code like the
> following for removing a certain prefix from a string:
>
> if url.startswith('http://'):
> url = url[7:]
If I came across this code I'd want to know why they weren't using
ur
On Fri, 11 Jul 2008 16:45:20 +0200, Christoph Zwerschke wrote:
> Bruno Desthuilliers schrieb:
>> DRY/SPOT violation. Should be written as :
>>
>> prefix = 'http://'
>> if url.startswith(prefix):
>> url = url[len(prefix):]
>
> That was exactly my point. This formulation is a bit better, bu
Bruno Desthuilliers schrieb:
DRY/SPOT violation. Should be written as :
prefix = 'http://'
if url.startswith(prefix):
url = url[len(prefix):]
That was exactly my point. This formulation is a bit better, but it
still violates DRY, because you need to type "prefix" two times. It is
exac
Christoph Zwerschke a écrit :
In Python programs, you will quite frequently find code like the
following for removing a certain prefix from a string:
if url.startswith('http://'):
url = url[7:]
DRY/SPOT violation. Should be written as :
prefix = 'http://'
if url.startswith(prefix):