Hi,
This behavior was changed in Spyder 4 (if I’m not mistaken) to prevent people from inadvertently using variables defined in the console when rerunning a file.
For instance, they could have removed a variable in their code that it’s still present in the console from a previous run. So this would give the impression that everything is working fine, when in reality it’s not (i.e. the code will fail to run in another person’s computer). So, I’d say chatGPT is right about this one in the sense that the code you’re trying to run doesn’t stand on its own. Furthermore, it’s a bad practice to write code like that and should be avoided as much as possible.
But you can revert back to the old behavior by going to the menu
Run > Configuration per file
and selecting there the option
Run in console's namespace instead of an empty one.
Cheers,
Carlos
--
You received this message because you are subscribed to the Google Groups "spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spyderlib+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/spyderlib/4a403439-4d4f-4d08-8c3c-5ae247c749ffn%40googlegroups.com.