Comments on my first script?

John Salerno johnjsal at NOSPAMgmail.com
Thu Jun 12 17:21:08 CEST 2008


"John Salerno" <johnjsal at NOSPAMgmail.com> wrote in message 
news:48513b9b$0$11197$c3e8da3 at news.astraweb.com...
>> if domain.endswith(".net"):
>> rec = clean_net(rec)
>>
>> if domain.endswith(".com"):
>> rec = clean_net(rec)
>>
>> if domain.endswith(".tv"):
>> rec = clean_net(rec)
>>
>> if domain.endswith(".co.uk"):
>> rec = clean_co_uk(rec)
>>
>> if domain.endswith(".info"):
>> rec = clean_info(rec)
>
> Hmm, my first thought is to do something like this with all these if 
> tests:
>
> for extension in [<list all the extensions as strings here>]:
>    rec = clean_net(extension)

Whoops, you'd still need an if test in there I suppose!

for extension in [<list all the extensions as strings here>]:
    if domain.endswith(extension):
        rec = clean_net(extension)

Not sure if this is ideal. 





More information about the Python-list mailing list