I have an issue whilst importing code into my program. I have a file dedicated to functions that I can call from anywhere inside my program. I use a function called clear(), which looks something like this:
def clear():
os.system("cls")
All this does is clears the terminal. Basically, I recently redid my code, and now whenever I use it anywhere in my program, it throws back one of 2 errors. Either:
File "C:\Users\Owner\Desktop\Programming\Python\project\main.py", line 90, in <module>
home()
File "C:\Users\Owner\Desktop\Programming\Python\project\homescreen.py", line 89, in home
main_menu()
File "C:\Users\Owner\Desktop\Programming\Python\project\homescreen.py", line 37, in main_menu
clear()
NameError: name 'clear' is not defined
If i import my functions like this: from functions import *
. Or this:
Traceback (most recent call last):
File "C:\Users\Owner\Desktop\Programming\Python\project\main.py", line 3, in <module>
from functions import *
File "C:\Users\Owner\Desktop\Programming\Python\project\functions.py", line 8, in <module>
from homescreen import home
File "C:\Users\Owner\Desktop\Programming\Python\project\homescreen.py", line 3, in <module>
from functions import clear
ImportError: cannot import name 'clear' from partially initialized module 'functions' (most likely due to a circular import) (C:\Users\Owner\Desktop\Programming\Python\project\functions.py)
If I import it like this: from functions import clear
A factor of this problem may be because my python program is spread across 3 files, but I couldn't find any illegal imports. Any feedback would be greatly appreciated! Thanks!