Forums

Reset Python from the console?

Is there any way to reset the interpreter from within a console? I tried a the hotkey from IDLE and it didn't work. I'd assume there is a command or something?

Thanks

I don't think there's a way to do that. The only reference I could find was on StackOverflow and the solution proposed didn't work fully.

Is there any way for you guys to implement this? Whenever I want to reset my console right now I have to kill, start, and re-share it and wait for my friends confirmation email.

You could probably come up with something that just calls del on the contents of locals() and globals(), but this won't unload and imported modules. In fact, judging from this bug report unloading modules isn't something that Python supports or is likely to support in the forseeable future.

You could share a bash shell instead of a Python prompt and then you could quit and restart the interpreter whilst leaving the console running. Anything you can do in bash you can also do with os.system() so I can't see how this is a security issue.

That's a good idea Cartoo. I'll keep it in mind, thanks!

Thanks, Cartroo -- a great suggestion, as always!