I like to organize my data analysis projects with a root folder containing a data folder (named data
) and a code folder (when I use R, I sometimes name it R
). When using Python, my code folder would logically be called python
. My project working directory is the root folder (containing both data
and python
folders).
I have multiple files of code in my python
folder. I would like to import one (let's call it file2.py
) from another, in an interactive python session. I have tried the following:
from .python import file2
However, this does not work because python
is a reserved word. If I rename the folder to something different, it works. Is there a way to escape the reserved word, or pass the file location as a string to the import? I'm frustrated because all the best alternatives (e.g., code
, scripts
) are also reserved words. My project organization is an oft-recommended best practice in R, and I'm hoping there's a parallel in Python.