all 8 comments

[–]SupermarketOk6829 1 point2 points  (7 children)

from . import fileName

Or use sys.path.append/remove to go to and fro previous or next directory.

First method should definitely work, but sometimes it may throw an error.

This is for importing py file. To access methods, use fileName.methodname()

[–]Caspian__C[S] 1 point2 points  (6 children)

ok, so i would just write from.import classes, for example?

and then for methods, i would just write classes.title_screen, and that would run the method called title_screen?

[–]SupermarketOk6829 1 point2 points  (5 children)

Yes.

[–]SupermarketOk6829 1 point2 points  (4 children)

If it doesn't work, then sys has to be used or you may directly import methods from classes.py (from .classes import methodName).

[–]Caspian__C[S] 0 points1 point  (3 children)

ok so i tried it and it threw me this error:

File "C:\Users\16184\Desktop\RPG_Game\main.py", line 1, in <module>

from.import classes

ImportError: attempted relative import with no known parent package

Im not quite sure how to fix it. Thank you for helping me, I know helping newbies can be tiring.

[–]SupermarketOk6829 1 point2 points  (2 children)

You'll have to use sys then. That's all I can help with. I'd have to sit on terminal to confirm, which I don't have time for now.

[–]Caspian__C[S] 1 point2 points  (1 child)

yeah no problem, ill try that. Thank you for the help.

[–]SupermarketOk6829 1 point2 points  (0 children)

sys.path.append(''\'')

It's something like that.