microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.33k stars 1.19k forks source link

code in floating window is not updated when doing an import #22718

Open nemar3 opened 10 months ago

nemar3 commented 10 months ago

Environment data

Expected behaviour

I am using the floating windows functionality , in the floating window, I have code that imports from another file a class I make changes to the file where I have the class (which is not in a floating window) then I execute the code in the floating window, I am using Shift+Enter to execute the selected lines I selected code, imports again the class and creates a new class instance. I am expecting this to reflect the code changes I did in the other file.

Actual behaviour

The code in floating window doesn't take into account the latest code changes in the import file

XXX

Steps to reproduce:

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

create two files: one file has a class and a method, call that file_a for example: class ABC(): def method(): a=5 print (a)

create another file, call that file_b, make it a floating window from file_a import * abc=ABC() abc.method()

no go that file_a and change the value from a=5 to a=10... run again the code in file_b with shift+Enter it doesn't update the value of a to 10

amunger commented 10 months ago

This is how notebook kernels behave, including in the jupyter web app - if you update an imported package, the kernel needs to be restarted before that update will take effect in the notebook.

nemar3 commented 10 months ago

I am actually not running a notebook ,or the interactive mode, I am running on the terminal. executing code with shift+enter. I a believe this is a problem with VS code, when I do the same with Spyder it works fine