Python Forum

Full Version: vs code interpreter vs IDLE feature
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have been using IDLE for quite a while now. I don't really know it super well, but it's pretty basic.

Recently, because VS Code is featured in so many tutorials, and so many tutorials need a feature that's not in IDLE, like a .dot file viewer, that I've switched to trying to learn how to use VSCODE.

HOwever, when I used to follow tutorials, I would sometimes use the variables and functions still loaded to the interpreter memory after the file finished , meaning I could play with the lists from a file etc. ,,, I don't know how to achieve this is VS CODE. so far, I can only see how I can either run a file, or run the interpreter from the terminal. I also don't know how to run files from inside the interpreter, which MIGHT be the solution I'm looking for, and after looking it up once or twice haven't had any success.

Is there a goto solution for this feature??
One way of achieving desired result is to run Python file in interactive mode in terminal.

python -i my_code.py


This has nothing to do with VS Code. It runs file and after that keeps session “alive”, so that names and functions are accessible.
(Mar-02-2019, 04:31 AM)tsmspace Wrote: [ -> ]Is there a goto solution for this feature??
Yes,what i use is cmder in VS Code or alone with ptpython or IPython.
Seamless VS Code Integration cmder
[Image: jGOt46.jpg]
[Image: Sl3qbO.jpg]

As mention can use -i i do use python,but eg ptpython -i my_code.py to get autocomplete and help.
Look at VS Code from start | Python environment Windows.
You may also have a look into "Run code selection in the Python Interactive window" feature available in February 2019 release of the Python Extension for Visual Studio Code (description is at the very end of linked article).
(Mar-02-2019, 04:31 AM)tsmspace Wrote: [ -> ]I have been using IDLE for quite a while now. I don't really know it super well, but it's pretty basic.

Recently, because VS Code is featured in so many tutorials, and so many tutorials need a feature that's not in IDLE, like a .dot file viewer, that I've switched to trying to learn how to use VSCODE.

HOwever, when I used to follow tutorials, I would sometimes use the variables and functions still loaded to the interpreter memory after the file finished , meaning I could play with the lists from a file etc. ,,, I don't know how to achieve this is VS CODE. so far, I can only see how I can either run a file, or run the interpreter from the terminal. I also don't know how to run files from inside the interpreter, which MIGHT be the solution I'm looking for, and after looking it up once or twice haven't had any success.

Is there a goto solution for this feature??

add -i option/argument in python terminal.

Steps-
1. Open settings.json file using command palette(ctrl+shift+p).
2. Add "python.terminal.launchArgs": ["-i"] , with all the quotes.
3. Save and run file as usual.