Reputation: 133
I am new to python. I am using the anaconda prompt to run my code. I am trying to import a class from another module but I keep getting errors such as cannot find reference to the class
.
P.S please don't negative mark this, or else I will lose the privilege of asking questions
I have already provided an __init__
function.
The module itself runs just fine.
I have used from parser import Parser
I have used from parser import *
statement as well
class Parser(object):
def __init__(self, tokens):
self.tokens = tokens
self.token_index = 0
from parser import Parser
I expected it to normally import the class, but it is unable to.
I keep getting the cannot import name 'Parser' from 'parser' (unknown location)
when I use from parser import Parser
Upvotes: 0
Views: 1707
Reputation: 398
parser
is also the name of a Python module in the standard library.
It's likely there is a name conflict, and that Python is importing the module from the standard library.
Upvotes: 1