Python Forum
Super simple import doesn't work. Please help!
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Super simple import doesn't work. Please help!
#2
I'm on the same version, also on Windows. Here's basically what it looks like you're doing:
E:\Projects\etc>python -V
Python 3.6.5

E:\Projects\etc>echo import other > spam.py

E:\Projects\etc>echo def something(): print("hi") > other.py

E:\Projects\etc>python spam.py

E:\Projects\etc>echo import other; other.something() > spam.py

E:\Projects\etc>python spam.py
hi
So what you're doing clearly works. Try renaming the folder/file. I don't know enough about the module system to be sure, but the file having the same name as the folder could possibly be confusing the importer? From what I know, the folder is only considered a module if it contains a file named __init__.py, but like I said, I don't know that for sure.
Reply


Messages In This Thread
RE: Super simple import doesn't work. Please help! - by nilamo - Jul-18-2018, 06:14 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020