I am trying to learn programming through Python, so I apologize in advance if this is an absurdly simple question.
I am attempting to simplify my convoluted directory structure and utilize some of Python's code-reuse features, I have encountered what is for me an inexplicable ImportError
error. For the past several hours I've been reading about Python's import
, module
, and package
features (here, here, here, and here among others), yet I remain unable to solve this (seemingly) simple error.
Here is the problem.
I have one directory (dir
), within which resides one sub-directory (subdir
). Each directory includes a few files. Thus, my overall directory structure looks like the following:
dir/
__init__.py
draw_lib.py
subdir/
__init___.py
drawing.py
In my drawing.py
file, I attempt to import draw_lib.py
with the following line: from dir import daw_lib.py
. It results in an ImportError: No module named dir
. Can anyone provide a quick explanation for why my drawing.py
file can't find my dir
directory? Thank you for any assistance. I'm completely lost and would really like to improve my code reuse and directory structure once and for all.