[Tutor] iterating in the same line

Jonas Melian jonasmg at SoftHome.net
Sat Aug 13 20:20:58 CEST 2005


I would check 3 words at the starting of a line

s=['foo','bar','qwe']

if ln.startswith(s):   (this is bad)

what is the best way for making it?

if max(map(ln.startswith,s)):
or
reduce(lambda m,n:m or n, map(ln.startswith, s))

Thanks!


More information about the Tutor mailing list