@
nilamo & @valcano63
I am, of course, not sure of the intent of @
Vai, but clearing the environment at the beginning of a script is commonly used to ensure that the results of the script are perfectly reproducible. It is considered 'Best Practice'.
Your intuition that this question was irrelevant, particularly in the context of an interactive session, seems counter-intuitive, given that @
Vai had a (good) reason for asking and that in a non-interactive session the environment would no longer exist after the scripted exited anyway.
@
Vai
The code from @
volcano63 is approximately equivalent to how this is done in R/R-Studio ("rm(list=ls())").
The link below has a similar code example.
It also states that "%reset" is the right answer, but that prompts for confirmation, which seems to me one step worse than having to click on the 'Reset the namespace' button on the 'Variable explorer' tab.
Also, Spyder's 'Code analysis' considers "%reset", as well as "!CLS", to be "invalid syntax", which seems terribly odd and like a deal-breaker.
https://github.com/spyder-ide/spyder/issues/2563
Actually, the response on Github was just incomplete. "%reset -f" is non-interactive, and, therefore, seemingly the best option.
That issue/CR did result in a configuration option to "Clear all variables before execution", but that breaks scripts that use caching (e.g., for not reloading large data files), so it does not suit my work-flow.