Live python update - in Vim/gvim

Subject says it all :slight_smile: I use gvim. Too dumb for emacs!
Is this possible? How would I rig it so I don’t have to keep running from scratch every time I poke a stick into the code?


to run the currently edited script:

:!python %

you can also map it to a key(binding) with something like:

map <F12> :!python %

in your vimrc

i’d also recommend using some python scripts from . there are some really nice ones.

my vim: 1 2

I meant - is there a way to have the app running,run(), and be able to cut-in “live” and make code changes?
I read a thread about doing this in emacs, so I hoped someone may have a clue for the other half :smiley:


Edited to add: Oh man, your vim looks so much better than mine! Vim envy, I haz it.

might be interesting for you:

ps: thanks :wink:

I had that link open in another tab, but wanted to see if anyone knew a simpler way. I guess I will download that OIDE and have a look.


Well, you can always start Python in interactive mode (-i flag), but this doesn’t work so well with Panda3d. You won’t actually get the interactive shell part until the run() task completes, so limited usefulness.

Another choice is using a Python debugger. I’ve never been able to get it to play along nicely with Panda3d, but if you could get it to work, it’s simple to interact with your Python code directly.

And finally, you can roll your own. There’s a Panda3d-based InteractiveConsole wrapper around on the forums that’s a good place to start. From here you can use the built-in Panda3d GUI to enter Python commands, as if you were using the standard Python console.

Now, this gives you the ability to interact with the Python interpreter as your game is running. But what about code changes? You’d like to edit something and then see how it goes, so you can use the reload(modulename) command to re-import a changed module. Note that this might result in some subtle bugs, depending on how your code is structured.

There’s a lot of caveats to re-importing a module, such as dangling external references. ie: If another module instantiates a class defined in a reloaded module, then reloading it will not update those class references. They will continue to point to the old definition.

Personally, I prefer using very small unit tests that restart from scratch upon each code change, instead of trying to dynamically reload changed code. However, as Nemesis already pointed out, someone has written a rather extensive IDE entirely in wxPython/Panda3d. I am assuming it makes extensive use of everything I mentioned above in order to function.

This is my understanding of how interactive Python editing works. Someone who is more experienced can set me straight if I am wrong. :slight_smile:

Thanks - I fetched the console, but I can’t get it to work. I asked over on the console thread, so will watch there.