I guess this works, I investigated the genuine streamlit document in my python/conda bin, and it had these lines:
import re
import sys
from streamlit.cli import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())
From here, you can see that running streamlit run APP_NAME.py on the order line is the equivalent (in python) as:
import sys
from streamlit import cli as stcli
if __name__ == '__main__':
sys.argv = ["streamlit", "run", "APP_NAME.py"]
sys.exit(stcli.main())
So I put that in another content and afterward run that content to run the first application from python, and it appeared to work. I don't know how cross-platform this answer is, however, as it actually depends fairly on command line args.
Want to learn python to gain more knowledge? Come and join the python training course