An implementation of a DFA in Python