I'm trying to make a lexer in python but when I try to import a class from file token.py I get this error
ImportError: cannot import name 'Token' from 'token'
the code for token.py is as follows
from enum import Enum
class Token():
def __init__(self, ttype, value=None):
self.type = ttype
self.value = value
def __repr__(self):
return {'type':self.type, 'value':self.value}
class TokenType(Enum):
NUMBER = 0
PLUS = 1
MINUS = 2
MULTIPLY = 3
DIVIDE = 4
LPAREN = 5
RPAREN = 6
and the import statement is
from token import Token, TokenType