pythonic-emacs/anaconda-mode

[documentation] put somewhere in the readme how to execute python files

kirk86 opened this issue · 5 comments

I'm coming from elpy and just installed anaconda-mode. In my config I've setup the following interpreter
(setq python-shell-interpreter "python" python-shell-interpreter-args "-i")

But there's no documentation on how to execute a python file?

For instance, in elpy I could

  1. mark a specific code block and execute it with C-c C-c
  2. execute the whole file using C-c C-c if not code block is marked
  3. execute a python file including ___main___ directive using C-c p
  4. all of the above but also specific conda envs using pyvenv, I suppose the equivalent is pythonic-activate but I'm missing steps 1...3 in the readme. Please specify how the users can achieve that and what additional config is required.

Thanks!

dakra commented

Those are functions provided by the default python package shipped with Emacs.
I never tried elpy but I think, unlike anaconda-mode, it's more a meta package which bundles and configures multiple python packages for you.

So without elpy you would start a python interpreter with run-python and then you can call python-shell-send-buffer, python-shell-send-region, python-shell-send-string etc to send the specified part to this python process.

Personally I can recommend the
jupyter console if you need
a repl (or org-babel integration).

Thanks, personally I like elpy and the only reason I was looking at anaconda-mode is because elpy brings a lot of other dependencies which I don't want/need cause they mess with my config.

So without elpy you would start a python interpreter with run-python and then you can call python-shell-send-buffer, python-shell-send-region, python-shell-send-string etc to send the specified part to this python process.

It would be nice if anaconda mode had those functionalities out of the box. Of course I can sit down and write a couple of functions and bind them to different keys or I'm sure if I search probably someone else might have already implemented it better than me, but the bottom line is that these days I can barely get time for sleep let alone spend time on fiddling around with emacs and different package configs that's why I was looking for something clean, complete and out of the box experience to replace the heavy on dependencies elpy.

dakra commented

python-mode already binds the python-shell-send-... functions to keys for you. So the only thing you have to do is start a python repl first (e.g. with M-x run-python) so it knows in which repl to eval the code.
I guess it's not a complete out of the box experience (especially if you have multiple repls with different python virtualenvs) but anaconda-mode doesn't say that it does all python things like elpy. (It also doesn't do formatting, pylint, installing packages etc etc).
We could certainly add some more convenient functions for evaling in the same process that anaconda runs in, but at least I don't have time for that in the foreseeable future and what's there is enough for my usecase.
(For more "playing around" I prefer to use org-babel anyway).

anaconda-mode doesn't do formatting, pylint, installing packages etc etc

So except from flycheck and pylint, do you recommend anything else?

dakra commented

I also use virtualenv, pippel, blacken, pydoc, isort and a few more.
This, of course, is all highly opinionated. You can check my config here