Ivar Fredholm <freddyho...@protonmail.com> writes: > At this point, Babel calls org-babel-execute:python, which decides, based on > the 'session' header, whether or not to call python3 tmp_code.py or to feed > each line in tmp_code.py into the session interpreter. What I am wondering is > if we could replace the code for the latter option (in ob-comint.el) by just > sending the interpreter the command 'exec(open("tmp_code.py").read())'.
ob-comint.el knows nothing about the interpreter. So, what you are describing should be implemented by the corresponding ob-*.el backends. They know all the details about the interpreter being used. Also, some interpreters behave differently if they run commands line-by-line vs. inside script file. In particular, the script commands may be echoed before their output in some cases (e.g. bash scripts and .bat files, AFAIR). Best, Ihor