3

[2016.12.23]: I'm trying to make emacs be usable for working with python code. By 'usable' I mean I could rely on it with code navigation and completion.

I'm using spacemacs + anaconda-mode for it, but I'm not 100% satisfied.

For example, when I try to visit definition of 'get' function with M-. (anaconda-mode-find-definitions), I end up with message: "no definitions found". On the other hand, PyCharm does the job with it.

#!/usr/bin/env python

from avocado import Test

class MyTest(Test):   # M-. on 'Test' ends up in test class. This is fine.

    def test_mine(self):
        myParam = self.params.get(key='myParm', path='/', default=None)  ## M-. on 'get' fails. PyCharm does the job.

if __name__ == "__main__":
    main()

I also tried to use elpy+jedi, but no luck as well.

What is Your experience with this simple example?

The code above uses avocado testing framework.

regards

[2016.12.27]: Below is another example, yet one I need, but hopefully also using more maintainable library, scapy: the packet forging library. All three imports are legal to execute the code, but only the last one makes emacs be able to jump to definition

#from scapy.all import *     # imports all from scapy.layers.all, but it is not enough for emacs to see IP() def.
#from scapy.layers.all import * # gets all from scapy.layers.inet, but it is not enough for emacs to see IP() def.
from scapy.layers.inet import *   #. ok with this.

packet = IP()
print packet.mysummary()

Question is is it possible to make emacs jump to definition when either first or second header is used instead of third one?

[2016.12.28]: Here is another example where my emacs python environment neither completes nor jumps to definition, although the code runs without error. it requires "pip install pyvim pyvmomi".

from pyVmomi import vim

vim.vm.CloneSpec()

How about Your emacs environments, do they handle such cases?

mat
  • 51
  • 5
  • Welcome to Emacs.SE! Please edit your post to ask a more discrete question. Explain precisely what the problem is. Show the relevant code from your init file. – Dan Dec 23 '16 at 17:46
  • 1
    I attempted to reproduce it but even after installing avocado package I am stuck with an import error when I do `from avocado import Test`. – syl20bnr Dec 23 '16 at 23:02
  • I had a little bit of experience with Intellij products for dynamic languages, but not Python (mostly Ruby). The thing is: often times it just guesses. As per your example, I wouldn't expect an honest code analyzer to suggest you any source for `get` method, or multiple possible sources. Finally, in Python it is possible to write code that generates methods dynamically, when they are called, so there isn't a universal way to find the source for a method - it simply may not even exist in your code base. – wvxvw Dec 24 '16 at 08:01
  • Please use some other example -- `avocado-framework` is a pain to install, making it hard to reproduce your example. – Ista Dec 24 '16 at 14:58
  • Thank You people for Your comments. I'll find another examples then. I'm starting with spacemacs+anaconda. I'm working with avocado at work (redhat install), and indeed trying to install it on ubuntu isn't that easy. – mat Dec 24 '16 at 22:19
  • Here is another example, yet one I need, but also hopefully using more maintainable library, scapy: the packet forging library. – mat Dec 27 '16 at 07:57
  • Maybe you want to ask the authors of these plugins about their opinions. If I'm not mistaken anaconda uses jedi internally. – politza Dec 28 '16 at 20:38
  • 1
    I use `jedi-core` + `importmagic` + `nose` + `py-isort` + `py-yapf` + `sphinx-doc` + `virtualenvwrapper` and happy with them. – Saddle Point Dec 30 '16 at 05:39

0 Answers0