Frage

So I tried to use parses generator waxeye, but as I try to use tutorial example of program in python using generated parser I get error:

AttributeError: 'module' object has no attribute 'Parser'

Here's part of code its reference to:

import waxeye
import parser

p = parser.Parser()

The last line cause the error. Parser generated by waxeye I put in the same directory as the init.py . It's parser.py .

Anyone have any idea what's wrong with my code?


Edit 20-05-2013:

Beggining of the parser.py file:

from waxeye import Edge, State, FA, WaxeyeParser

class Parser (WaxeyeParser):
War es hilfreich?

Lösung

It might be that the parser module you're importing is not the one you want.

Try inserting a:

print parser.__file__ 

right after the imports, or try naming your parser module differently.

Also, if working with Python 2.7 its good to enable absolute_imports from the __future__ module.

Andere Tipps

Python already has a module named parser. The import statement will load system parser module instead of local parser.py file. The simplest way to fix this issue is to change the filename of parser.py. For example, xxparser.py.

import waxeye
import xxparser

p = xxparser.Parser()
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top