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, but it > still violates DRY, because you need to type "prefix" two times. It is > exactly this idiom that I see so often and that I wanted to simplify. > Your suggestions work, but I somehow feel such a simple task should have > a simpler formulation in Python, i.e. something like > > url = url.lstripstr(('http://', 'https://'))
I would prefer a name like `remove_prefix()` instead of a variant with `strip` and abbreviations in it. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list