Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs plugin to list all methods in a python module

Tags:

python

emacs

Is there a emacs plugin which lists all the methods in the module in a side pane.

I am looking for a plugin which has keyboard shortcuts to show/hide all the methods in python module file currently opened.

like image 372
user462455 Avatar asked Aug 28 '13 04:08

user462455


People also ask

Which library function returns the list of all functions in a module?

The dir() function The dir() built-in function returns a sorted list of strings containing the names defined by a module. The list contains the names of all the modules, variables, and functions that are defined in a module.

How do I display the contents of a Python module?

We've then used the dir () function to display the attributes provided by the module. Here is a brief description of the attributes: Bye, Welcome – the functions provided by the module. __builtins__ – a listing of all the built-in attributes that are accessible from the module.

How do I list all methods in a Python module?

We can list down all the functions present in a Python module by simply using the dir() method in the Python shell or in the command prompt shell.

Which command is used to see all the functions in a particular library Python?

You can use dir(module) to see all available methods/attributes.


3 Answers

For the first question, use M-xspeed-bar, like Alex suggested.

For the second, enable hs-minor-mode, M-xhs-minor-mode, and use C-cC-@C-S-h to hide all methods, and C-cC-@C-S-s to show.

like image 134
Bleeding Fingers Avatar answered Oct 23 '22 02:10

Bleeding Fingers


I suggest using elpy.

C-c C-o runs elpy-occur-definitions which creates a new buffer with a list of all the class and function signatures.

You can navigate the list using C-n and C-p. The mode works with next-error-follow minor mode. So C-c C-f inside the buffer enables jumping to the class or function definition selected.

Here's an example of the contents of that buffer:

8 matches for "^ *\(def\|class\) " in buffer: leveling_utils.py
 11:def leveling(episodes_with_potential_associations_by_member):
 26:def _apply_leveling(sorted_episodes):
 41:def _set_non_chronic_associations(episode):
 73:def _apply_sub_to_procedural_association(assoc):
 94:def _set_chronic_associations(episode):
102:def _set_associations_for_self(episode):
118:def _set_to_actual(association):
122:def _log_actual_associations(member, leveled_episodes):

By the way, it has many other useful features that to me, make it a necessary addition to python-mode.

like image 29
Jerry Mindek Avatar answered Oct 23 '22 01:10

Jerry Mindek


You can look to ECB (it's better to take my fork of it, as it's adapted to fresh Emacs & CEDET) - it can display information about source code fetching it from Semantic (CEDET subpackage) or via imenu (for languages that aren't supported by Semantic).

Speedbar (included into GNU Emacs) can also show a list of top level objects, but doesn't show differences between imports, functions of other top-level stuff

like image 2
Alex Ott Avatar answered Oct 23 '22 02:10

Alex Ott