def findall(s, sub):
    """Returns all indices of 'sub' within 's', as a list"""
    ret = []
    cur = 0
    while 1:
        n = s.find(sub, cur)
        if n < 0: return ret
        ret.append(n)
        cur = n+1
    return ret