I have a problem. When I try to make a class instance, I get an error. Here's some code:
import parser
def main():
tokens = [["TYPE_ONE", "value one"], ["TYPE_TWO", "value two"]]
parse = parser.Parser(tokens)
parse.parse()
main()
And parser.py:
class Parser(object):
def __init__(self, tokens):
self.tokens = tokens
self.token_index = 0
def parse(self):
while self.token_index < len(self.tokens):
token_type = self.tokens[self.token_index][0]
token_value = self.tokens[self.token_index][1]
print(token_type, token_value)
self.token_index += 1
But the script gives the following error:
Traceback (most recent call last):
File "C:/Users/edyal/OneDrive/Desktop/Paigoa/src/main.py", line 8, in <module>
main()
File "C:/Users/edyal/OneDrive/Desktop/Paigoa/src/main.py", line 5, in main
parse = parser.Parser(tokens)
AttributeError: module 'parser' has no attribute 'Parser'
parsermodule from the stdlib by accident.parsermodule from standard library. Please, show your directory structure