Naive implementation of KMP algorithm
Minor comments, but...

    else:
        if table[i] &gt; -1:
            m += i - table[i]
            i = table[i]
        else:
            m += 1
            i = 0


This sort of construct, an else which contains only an if-else chain, can be simply written as an elif-else chain.

    elif table[i] &gt; -1:
        m += i - table[i]
        i = table[i]
    else:
        m += 1
        i = 0




        table[position] = candidate + 1
        candidate += 1


These statements seem weird, why not first add one and then set?

        candidate += 1
        table[position] = candidate