[Tutor] Python 2.7.1 interpreter question

Steven D'Aprano steve at pearwood.info
Wed Dec 29 21:34:06 CET 2010


Frank Chang wrote:

>       When I use the Python 2.7.1 interpreter I get the following traceback
> :
> 
> F:\shedskin\shedskin-0.7>python automata_test2.py
> Traceback (most recent call last):
>   File "automata_test2.py", line 23, in <module>
>     list(automata.find_all_matches('nice', 1, m))
> AttributeError: 'module' object has no attribute 'find_all_matches'
> 
>      Could anyone help me fix this error? I am new to python. Thank you.

This error tells you that the module "automata.py" does not have a 
global-level object called "find_all_matches".

If you look at the module, you will see it does not have a global-level 
object called "find_all_matches", exactly as Python tells you. To fix 
this, you need to either:

(1) Give the automata module a function "find_all_matches" that does 
what you expect it to do; or

(2) Change automata_test2 to create a DFA instance, then call the 
find_all_matches method in that instance. Something like:

instance = automata.DFA(start_state)
instance.find_all_matches("word", k, lookup_func)


-- 
Steven



More information about the Tutor mailing list