Python Forum
How to clear IPython console in Spyder?
Thread Rating:
  • 2 Vote(s) - 2.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to clear IPython console in Spyder?
#8
@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.
Reply


Messages In This Thread
How to clear IPython console in Spyder? - by Vai - Jun-22-2018, 03:35 PM
RE: How to clear IPython console in Spyder? - by james_balcomb - Aug-20-2018, 09:43 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Spyder console zoom in not working? Dionysis 2 459 Feb-06-2024, 03:31 PM
Last Post: paul18fr
  IPython errors for numpy array min/max methods muelaner 1 566 Nov-04-2023, 09:22 PM
Last Post: snippsat
  Can a program execute code in iPython shell and get result? deanhystad 3 1,747 Jun-17-2022, 03:45 AM
Last Post: Larz60+
  Spyder Quirk? global variable does not increment when function called in console rrace001 1 2,233 Sep-18-2020, 02:50 PM
Last Post: deanhystad
  IPython console vs Spyder script losc 3 2,735 Apr-30-2020, 04:57 AM
Last Post: deanhystad
  How can I create a multiline input in ipython? DataMower 3 4,383 Oct-28-2019, 08:50 PM
Last Post: DataMower
  ipython autocomplete broke indentation! Exsul 6 4,547 Aug-20-2019, 01:29 AM
Last Post: Exsul
  spyder - won't show results in console kbrummert 0 4,285 Jan-20-2019, 01:11 AM
Last Post: kbrummert
  Stopwatch in Python/IPython shell suvadip 3 4,312 Jul-06-2018, 01:51 PM
Last Post: snippsat
  PyEDA-IPython Problem [Graph] embash 5 4,524 Jun-02-2018, 06:40 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020