[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Using exec functions to simplify session code
From: |
Ihor Radchenko |
Subject: |
Re: Using exec functions to simplify session code |
Date: |
Sun, 26 Jun 2022 12:33:39 +0800 |
Ivar Fredholm <freddyholms@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