In Ruby there is a gem called interactive_editor which allows entering a vim session when entering vi in Ruby interpreter.
Literally we need to require interactive_editor.rb in ~/.irbrc file, like this:
require '~/interactive_editor.rb'
And we are done. When we do vi in interactive session; vim is launched. As soon as we quit the editor, the code inside the vim session is executed. Here is more information about running vim within irb.
So, is there any equivalent to that in Python?
A possible way of (re)loading the module:
and anytime you import this into the interpreter, it is recommended to make a wrapper manually:
because
globals()called in a python file holds the file’s globals, not the interpreter’s. I know, it’s not elegant. But I’d recommend to reload module manually likereload(modname), it gives you more control, though may be tedious.