I mean, yeah. You just import the Python module you're writing and you can call any function or inspect any object you want. iPython even has hot reload
I mean, yeah. You just import the Python module you're writing and you can call any function or inspect any object you want. iPython even has hot reload
Unless you've figured it out? In which case please say, because I want to code python like this.
Specifically I write code in my editor, hit a keystroke and all the code at the cursor gets sent to my running python and evaluated. The editor needs to be aware of python's indenting rules so it can do this, but once again if you've worked out a nice way to do this please say. Minimal keystrokes required would be great =)...
I'm not really requiring that the evaluated output gets sent to the editor, though of course that would be ideal, because in the worst case I can side-by-side the editor and the terminal.
From my perspective jupyter notebooks get kind of close, but I'm not coding in a file, so it's not quite ideal.
...I call this "copy/paste". And since I use X clipboard and a tiled window manager, it's only a couple keystrokes and no mouse. Highlight the code in the editor, "super+<direction>" to switch windows, "shift+insert" to paste.
There's a reason I'm specifying specific actions, I can easily see increasing the cognitive burden breaking the ease of that workflow. You can't tell me that putting your cursor to a code block and hitting a key is the same as selection, copy, swap to console, paste...
I've certainly had situations where I've done what you're describing and then still taken the extra time to setup the workflow I've described above because it's worthwhile when you're trying to debug a knotty problem.
Is there a shortcut to evaluate the code in the correct module/namespace for Python? Maybe to switch the namespace in which the Python REPL evaluates the code you paste in?
Docs: https://code.visualstudio.com/docs/python/jupyter-support-py A short demo on YouTube: https://www.youtube.com/watch?v=lwN4-W1WR84
Here's the fork that I'm currently using https://github.com/grusky/slimux
I use it with python and node.is and MySQL and psql
It's great because it can work with any REPL.
I used to use jupyter notebooks but almost exclusively use slimux now unless I need to some data visualisation or computer vision.
VS code's ipython REPL is quite good and has support for images and graphs.
I will say that the main thing that triggered a REPL driven workflow was dealing with large state. When you do machine learning and you have to deal with large models and datasets, loading them each time you save your code and triggering a unit test really gets tedious. You can definitely do it with caching and reducing the dataset size, but it only gets you so far IMO. There's nothing like being to inspect the state of your environment. Particularly when it takes a long time to create that state.
One important thing to keep in mind though is that it is not as dynamic as Lisp, so things like re-evaluating a class definition does not update existing objects. I end up restarting the python process and evaluating the buffers I'm working on often enough that I've bound it to its own key.
I've not used emacs for python, but could give it a spin for this!
Bit unfortunate that you need to restart the process for re-evaluating classes though.
It's one of the main reasons why I love Common Lisp so much.
Still, it's not too bad and IMO a lot better then restarting the process on every single change