Comparison of Python modes for Emacs

2024/11/19 0:22:44

So I have Emacs 24.3 and with it comes a quite recent python.el file providing a Python mode for editing.

But I keep reading that there is a python-mode.el on Launchpad, and comparing the two files it jumps out to me that the former is under 4000 lines, while the latter is almost 20000. This suggests that the latter is much more feature-rich.

And I can't find any online feature comparison about them, documentation, or at least a list about the features for each of them. Yep, there is syntax highlighting and embedded interpreter, but what about completion in shell buffer, completion in source file buffer, autoindent, reindent etc.

So what are the important features of these modes? (Or any other Python mode for Emacs which you recommend.) Please provide detailed answers.

Answer

I was python-mode.el user once but quit using it a year ago because I felt the way it was developed was not well organized. Here is a list from the note I took at that time. But I need to warn you that almost a year is passed since then so the situation may be changed.

  1. Many copy & paste functions.
  2. Many accidentally working code. For example, not passing around variables but using implicit binding. This produces many compile errors (and will not work if you change it to lexical scope).
  3. Rough granularity of commit. I send a patch, and it was committed with unrelated changes.

One thing I like about python-mode.el is it comes with automated test set (although I've never run it). python.el does not have a test set yet. But I know the author of python.el is writing it now.

While python.el is compact, it does not mean you get poor functionality. It is more like keeping core small and let others to extend it by providing concise API. Same author of python.el wrote python-django.el to extend python.el for django projects. I wrote auto-completion plugin for Python called Jedi.el and advanced IPython plugin called EIN. Both of them have better support for python.el than python-mode.el (well, that's because I don't use python-mode.el, though).

I had a few thing I missed from python-mode.el first, but they are quickly fixed in python.el (Of course, this probably means that I was not using so much functionality in python-mode.el).

what about completion in shell buffer, completion in source file buffer, autoindent, reindent etc.

  • completion in shell buffer: It sort of works in both python.el and python-mode.el. But sometimes it does not work if you have bad combination of Emacs version and python(-mode).el version. So probably python.el is safer in this manner. But if you want better solution, use EIN :)

  • completion in source file buffer: Just use Jedi.el :)

  • autoindent/reindent: I don't know which one is better in performance-wise. However, keybind for return differs one to the other. In python-mode.el, if you type RET you get autoindent. In python.el, RET does not give you indentation and you should use C-j instead. Actually C-j for newline+indentation is universal behavior in Emacs. So python.el is better if you do programming in other languages.

https://en.xdnf.cn/q/26502.html

Related Q&A

Python best formatting practice for lists, dictionary, etc

I have been looking over the Python documentation for code formatting best practice for large lists and dictionaries, for example,something = {foo : bar, foo2 : bar2, foo3 : bar3..... 200 chars wide, e…

TypeError: string indices must be integers, not str // working with dict [duplicate]

This question already has answers here:Why am I seeing "TypeError: string indices must be integers"?(10 answers)Closed 28 days ago.I am trying to define a procedure, involved(courses, person…

Pandas: create dataframe from list of namedtuple

Im new to pandas, therefore perhaps Im asking a very stupid question. Normally initialization of data frame in pandas would be column-wise, where I put in dict with key of column names and values of li…

Closest equivalent of a factor variable in Python Pandas

What is the closest equivalent to an R Factor variable in Python pandas?

Temporarily Disabling Django Caching

How do you disable Django caching on a per checkout basis?Back before Django 1.3, I could disable caching for my local development checkout by specifying CACHE_BACKEND = None, in a settings_local.py i…

How to get a complete exception stack trace in Python

The following snippet:import tracebackdef a():b()def b():try:c()except:traceback.print_exc()def c():assert Falsea()Produces this output:Traceback (most recent call last):File "test.py", line …

python - should I use static methods or top-level functions

I come from a Java background and Im new to python. I have a couple scripts that share some helper functions unique to the application related to reading and writing files. Some functions associated …

Draw graph in NetworkX

Im trying to draw any graph in NetworkX, but get nothing, not even errors:import networkx as nx import matplotlib.pyplot as plt g1=nx.petersen_graph() nx.draw(g1)

Django 1.7 migrations wont recreate a dropped table, why?

Using Django 1.7 migrations.I accidentally dropped a table in my database. I assumed that by running migration again this would recreate the table but no, Django states "No migrations to apply&quo…

Reset ipython kernel

I was wondering if there is a way to restart the ipython kernel without closing it, like the kernel restart function that exists in the notebook. I tried %reset but that doesnt seem to clear the import…