Closed dmn-seasony closed 4 weeks ago
Hi. I'll take a look but here some past solution that didn't work out:
%run -i .../code.py
option.As for printing the last line. IPython terminal by default doesn't print unless the code explicitly calls print()
or a variable by itself being called in the terminal. Changing IPython terminal behavior is out of scope of this extension. So a compromise is that you can highlight the variable (double click or other selection method) and Run Selection (F9)
handles the sending of text to the terminal. Also, consider the following:
for i in range(4):
ii = i + 1
if False:
ii + 3
How should ii
be printed? Every line or just last line? It is ambiguous and there will be use-case where neither one works. In the if
case, it should never be printed but to know when to print would requires knowing the code / sequence of event vs. current workspace variable; i.e., a real big mess! So, for now, the likely best apparent answer is that you as a developer should explicitly use print when appropriate and use highlight + F9 to print specific workspace variable you like to see.
Onto the seeing the exact code being executed question. One way is to open the code.py
in an editor like below. VSCode update code.py
and you can see the changes live.
Hope this helps and thank you for posting! Any suggestion or comment are always welcome and appreciated.
If I execute the
ipython.runSelections
command with a single line selected, the line is directly copied to the terminal and executed. However if I select multiple lines or use theipython.runSection
command, the code instead gets saved to a file (~/.vscode/ipython/code.py
) and executed with the%run -i
magic.However I would like to be able to directly see the lines that are executed in the terminal, and to see the return value of the last line (without explicitly using
print
), same as if I had typed the code directly into the terminal. It works fine to just copy the code and paste it into the terminal but that is cumbersome to do manually. Would it be possible to do that with this plugin?