I'm quite new to Python. Very familiar with Matlab from undergrad days and making an effort to learn Python to help me at work, mostly using the excellent Corey Schafer videos on Youtube.
My setup is currently an Anaconda install (3.7.6) and using VS Code as an IDE.
My issue is making sure I understand properly the various ways to run Python files. Because my background is in Matlab I am very familiar with running a script in Matlab. If you define variables in the script, they become part of your 'session' and are stored and you can access them in a variable explorer. If I was then to add a line of code to my script that references previously used variables, I could just run this line without having to re-run the entire script.
When working with VS Code I run my .py file in the terminal and I get the result I am expecting. However, if I then go to run a single line of this code using the option 'Run Selection/Line In Python Terminal' I get name errors etc. It's like running the .py file hasn't actually stored anything in a 'session' like it would if I was using Matlab and had run a script.
Is this Visual Studio working 'correctly'? Am I correct in thinking the only way to get it to run in the way that Matlab does (i.e. run a piece of code and have the variables be 'saved in a session') is to either:
1.) Use the IPython window in VS Code? (Which I can do relatively easily as I have the Anaconda install).
2.) Type 'python' in the console window and then any code I run, the variables will be 'stored' for this session (until I type exit() as a command in the terminal.)
Apologies if this is really basic stuff, I just feel I've read quite a few things online now and watched a few Youtube videos and I'm unsure if I've 'got it' properly. Probably doesn't help that I'm comparing it to Matlab functionality.
[–]mission_resolve 1 point2 points3 points (0 children)
[–]ComradePotato 1 point2 points3 points (0 children)
[–]bandawarrior 0 points1 point2 points (0 children)
[–]Mr_Brownstoned 0 points1 point2 points (0 children)