0

I checked online and on SO for answers but could not find anything helpful. It could possibly be because what I am looking for exists but I do not know the exact terminology. I am mainly interested in a solution that works in jupyter notebook.

To make it very simple and quick, let's consider the example of when we need to use Adam(). If we know the exact path, we would simply import it first:

from tensorflow.keras.optimizers import Adam

Now if we don't know the path, or the path has changed (like how now it is inside tf.keras instead of keras), is there a functionality to get help in jupyter notebook? Let's say we type Adam() and that functionality displays a list of possible paths to modules where functions named Adam() are defined. This would be a big asset in cases of coding without access to internet to look for the exact module path.

Wazaki
  • 899
  • 1
  • 8
  • 22
  • You are looking for autocompletion of module/function names. Typically IDEs (such as pycharm) offers this, but [there can be issues](https://stackoverflow.com/questions/49520815/pycharm-autocomplete-for-imported-modules). For Jupyter notebook, you may [refer to this thread](https://stackoverflow.com/questions/45390326/how-to-get-autocomplete-in-jupyter-notebook-without-using-tab). – metatoaster Jun 10 '21 at 04:40
  • @metatoaster But isn't autocompletion for helping when typing. Like if I start typing `from tensorflow.k` it would suggest `tensorflow.keras` and other possible modules starting with k? My question is more like: I try to use a function without importing its module and I get suggestions of modules to import. – Wazaki Jun 10 '21 at 04:49
  • I guess you are looking for the inverse of typical autocomplete, where you start with a known class name and find the module (rather than working from the root down). – metatoaster Jun 10 '21 at 04:51
  • @metatoaster Yes exactly !! – Wazaki Jun 10 '21 at 04:53
  • Since nearly all use case assumes the top down approach, the underlying autocomplete package [`jedi`](https://pypi.org/project/jedi/) likely optimises for that. However, you may wish to study that package and see if you can get it to go the opposite direction (i.e. start from some class). Maybe there is an API call in there that will get you a list of all possible imports so you can make an index based on all the leafs (i.e. classes/methods that can be imported). – metatoaster Jun 10 '21 at 05:18
  • @metatoaster I was hoping that there might already be a solution since it's hard to keep track of all the module paths, especially when upgrades shuffle that. It will probably require a search in all the existing modules and submodules to find the functions, so the top down approach might still be needed (unless we hash all existing functions' names) – Wazaki Jun 10 '21 at 06:50

0 Answers0