0

Is there a function that can be called from within the Python console that has the exact same effect as doing the following:

Calling

   exit()

to exit the console, followed by calling

python

at the command prompt to re-enter a fresh python console.

NB: I am not seeking to just clear or de-clutter the screen, because using CTRL+L accomplishes that quite easily.

nutbunny
  • 79
  • 1
  • 7
  • 1
    Are you looking for this https://stackoverflow.com/questions/26545051/is-there-a-way-to-delete-created-variables-functions-etc-from-the-memory-of-th?rq=1? – Sparky05 May 18 '19 at 13:57
  • @Sparky05 I think that ***is*** what I am looking for, although I'm not 100% sure since I am very new to all of this. The question you directed me to does seem to give advice on how to go about cleaning out all the gunk accumulated during a session of messy learning in the shell. I see that if one is working in `IPython` or `Jupyter`, one can benefit by directly using a `%reset` or `reset` instruction. Thank you for the re-direction. – nutbunny May 19 '19 at 11:46
  • 1
    If you are new to python, I would highly recommend ether working in a Jupyter notebook or some IDE (choice depends on your use case). Jupiter notebooks have the functionality of restarting the kernel and executing all cells, which can be very useful. – Sparky05 May 19 '19 at 13:40

1 Answers1

1

If you want to get rid of the variables defined in the session then this should do your job.

import gc

del <variable_name>
gc.collect()
David Buck
  • 3,752
  • 35
  • 31
  • 35
NGS
  • 21
  • 2