How streamlit handles the relative imports

I have a main script and inside the main script i am importing another script from the same directory. this import is not streamlit page its just a plain python code script. i am curious, how streamlit understand the relative import and read the corresponding file? It is good if you can point me to the related code in streamlit repo.

Absolute and relative imports are just good old python features, I don’t think using streamlit makes any difference.

when we start streamlit server with streamlit run script.py streamlit reads the script.py file and put the code in dummy module. what if script.py file imports another script how streamlit read those file?

As far as I know, streamlit doesn’t read the files you import. It just reads your main script and runs it, then import statements in your code are executed the same as any other statement.

image
Than you so much for guiding me. i got the idea, script will be imported as standard python feature because streamlit is adding script path in sys.path

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.