I made a simple class in a file that is in the same directory to where I'm trying to send it. However, for some unknown reason I can't for the life of me figure out why the import won't work. Any help would be great.
I've googled around a lot already but can't find anything specific to me
the class in question (file named location1.py)
class Location:
def __init__(self, name, txt_display, been_there):
self.name = name
self.txt_display = txt_display
self.been_there = been_there
all my imports (file named mainPart1.py)
import random
from tkinter import *
from location1 import *
from PIL import ImageTk, Image
how I'm testing it
temp = Loction("1a", "display poo", True)
print(temp.name)
"NameError: name 'Loction' is not defined" I get this from the terminal and I don't know what to do. I expected "1a"
答案 0 :(得分:2)
You have a typo there, it should be Location
Your code:
temp = Loction("1a", "display poo", True)
Should be:
temp = Location("1a", "display poo", True
)