On Fri, Sep 30, 2011 at 11:30 AM, Tarek Ziadé
<ziade.tarek@gmail.com> wrote:
Hey,
not sure how people do this, or if I missed something obvious in the
stdlib, but I often have this pattern:
starts = ('a', 'b', 'c')
somestring = 'acapulco'
for start in starts:
if somestring.startswith(start):
print "yeah"
So what about a startsin() method, that would iterate over a sequence:
if somestring.startsin('a', 'b', 'c'):
print "yeah"
Implementing it in C should be faster as well
same deal with .endswith I guess
I tend to do something like this a lot;
any(somestring.startswith(x) for x in starts)
Probably enough that having a method would be nice.