Welcome to the Treehouse Community
Looking to learn something new?
James Ball2,073 Points
Import from characters vs. import from characters.py
Why does "from characters import Thief" work but not "from characters.py import Thief"? Why do you not have to specify the filename extension when importing?
Here is a detailed explanation of importing in Python.
Importing uses dotted paths to navigate directories so
characters.py would specify a file named
py.py in a
characters directory. I put together a workspace to demonstrate. To use enter
python test.py in the console. There are comments for each of 4 tests in test.py.
I'm still testing myself (like what happens with a file named characters.py.py, or if there is directory and file with the same name in the same directory) so I may add more later.