This works out of the box in VSCode?
Just open a .py file, then select the snippet of code you want to run and cmd+enter
It will open a new REPL for you (using your selected interpreter) the first time, and after that all commands are run in that same one.