1

I'm looking for an extension which will help in Python's auto complete feature in Python.

If I type the following code:

a = [4,5,6]
a.p

Then I expect it would give me a suggestion for pop as it is one of the method of Python list. Is this thing achievable in Emacs?

I tried installing Rope, Rope mode, Ropemacs and Pymacs. The auto-complete suggestion, I get from that aren't the methods of list. But it suggests me something like print etc. Am I doing something wrong ?

Sibi
  • 47,472
  • 16
  • 95
  • 163

3 Answers3

3

Try Jedi.el. AFAIK, it should support your example.

Dmitry
  • 3,625
  • 2
  • 30
  • 28
0

Because Python variables don't have types, it is difficult to know what class of object a variable would contain at a given point in your code. Imagine if your code later did a = 1. Emacs would have to know when the variable a refers to a list and when it refers to a number in order to offer the correct completion. Generally this is not possible without actually running the code.

Ryan C. Thompson
  • 40,856
  • 28
  • 97
  • 159
  • The completion code would need to use some sort of parser for that, but that's not impossible. Also, offering some not-100% accurate completions is often better than offering none. – Dmitry Jan 21 '13 at 02:29
  • No, a parser is not sufficient to determine the type of a variable in a dynamically typed language. In some cases out is possible to make a guess about the type of a variable at a particular location in the code, but that won't work for things like function arguments, which have no you're hints at all. It's not impossible, but it's possibly harder than just writing a statically-typed language instead. – Ryan C. Thompson Jan 21 '13 at 03:08
  • In general, yes, it's hard. In the given example, not so much. We'd only have to worry about reassignments and nested scopes, which should be manageable with just a parser. – Dmitry Jan 21 '13 at 03:53
0

Works for me with vimrope from https://github.com/python-rope/ropevim/ (now, the official home of all rope projects)

mcepl
  • 2,688
  • 1
  • 23
  • 38