Reputation: 497
I know there's many questions with the same title, but non like my problem.
I'm trying to use a class from a another script on a new script, but I get an indent error on the same line I'm importing the script. It's odd cause there's no indentation or spaces and I've checked. Backspaced many time and nothing. Here's the .py
where I'm importing the class:
from logInScreen import checkValidation #the undexpected indent is on this line
class hello:
cv = checkValidation()
def show(self):
print(self.cv.user)
h = hello()
h.show()
THIS IS JUST AN EXAMPLE! I named the hello
class differently.
This is a bit of the class I'm trying to import from another .py
. I'll show just before the 1st method cause That's all I'm using.
class checkValidation:
fail = 0
user = "name"
password = "1234"
Here's I picture of the error:
I know it sounds stupid, but I can't seems to find a way to fix it. I made sure both scripts are on the same folder.
Upvotes: 0
Views: 507
Reputation: 280182
Your problem has nothing to do with any of the code you've posted. The traceback shows that on line 61 of logInScreen.py
, the line
os.system("mainPage3.py 1")
is indented more than it should be. Take a look at that line and the lines surrounding it, and figure out what level it should be indented to.
If the indentation looks fine, see if you're mixing tabs and spaces. If you are, convert the tabs to spaces. Python handles tabs like Notepad does, as enough spaces to reach the next 8-space indentation level. That is almost certainly not what you were expecting.
Upvotes: 3