I am getting an error when I run my python code
This is my exceptions class (exceptions.py):
#!/usr/bin/env python
class ConnectError(Exception):
def __init__(self, arg):
# Set some exception infomation
self.msg = arg
Here is my connector class (connector.py):
#!/usr/bin/env python
import exceptions
class CardReader():
def __init__(self):
raise exceptions.ConnectError("ABC")
Here is my test file(test.py):
#!/usr/bin/env python
import connector
connect = connector()
This is what my code sorta looks like, I know that I should use a try and except in my test file, but before I get to that I get an error in the connector class (AttributeError). I have tried using
from exceptions import ConnectError
but that gives me an ImportError: cannot import name ConnectError, I have tried using this:
from exceptions import *
then I get NameError: name 'exceptions' is not defined, then I tried:
from exceptions import *
import exceptions
I still get AttributeError: 'module' object has no attribute 'ConnectError', I have flipped the import statements and I am stuck. I've been searching online, but I can't find anything that has helped.
I solved my issue, i renamed my exceptions.py to expection.py, i'm not sure why but i think the name was effecting something, i used the regular import exception. thanks for the help :D