Anyone looking for the answer to this question: This answer worked perfectly!
I am making a program that will store X and Y coordinates for positioning on a target. I will then use it to calculate average shot position for a series, etc..
When I first started making the program I had all files in the same folder I opened in VSCode, which worked. It got out of hand and I put the files into categorized folders and started reading about packages. I can't get them to work though.
I've read answers to questions on StackOverflow, I've used examples from other sites (which don't work for me), I've even used the Python documentation which hasn't worked.
Things I've done:
- Updated my Python version from 3.7.4 32-bit to 3.9.1 64-bit
- Tested line for line this example (What doesn't work is importing from higher files into a lower one and Py-lint tells me that importing security.py from init.py in the MyPackage directory shouldn't work yet it does)
My code and file structure:
myPackage\
security.py
subfolder1\
item.py
subfolder2\
student.py
user.py
subfolder3\
accounts.py
registration.py
#from __init__.py in myPackage
import security
from subfolder1.subfolder2 import user
lol = security.lol()
print (lol)
x = user.testing()
print(x)
- Tested this example from Python docs which doesn't work at all for me.
test\
program.py
package\
subpackage\
lol.py
subpackage2\
#from program.py
import package.subpackage.lol
x = lol.test1()
print(x)
- And of course tested all sorts of examples here on SO
I have no idea how sys works or how path works so solutions of that kind need a little explanation and are not really desirable.
Honestly run out of ideas at this point. The file structure of my own program is a little big and there is too much code to get into in my opinion. If anyone knows how to fix these issues and can explain how inter-package imports work (one file in a package to another in the same package) like in the Python docs, how to import from a higher file to a lower, and from a lower file into a file inside the package I would be more than happy.
Tall order I know! I can't find these answers and the answers I do find don't work, thank you for any help you can provide!