Reputation: 81
I've the next folder structure (btw Python 3.7):
roots_folder/
main.py/
vk/
vk.py
sa/
sa.py
main.py files goes like this:
...
import vk
def main():
vk.test() ----> module 'vk' has no attribute 'test'
if __name__ == '__main__':
main()
vk.py files itself:
def test():
print('test worked')
I cannot understand the logic behind all this import thing. I've tried many variations based on lots of other answers, but it simply doesn't work.
If someone could suggest some kind of solution or point me towards how it's generally should be working, I would be very grateful!
Upvotes: 0
Views: 548
Reputation: 26
import will attempt to call the _ _ init _ _.py file within the module. You however do neither have that file, nor is it calling the vk.py file.
Simply renaming your vk.py to _ _ init _ _.py worked for me.
For more info on the way the import system works check out the Documentation: https://docs.python.org/3/reference/import.html
Upvotes: 1