Namespace resolution for auto-completion regarding

Hi everyone. I’ve recently stumbled upon this behavior in which when you load a sampler from you don’t get any autocompletion or namspace resolution (I don’t know if that’s the correct name). So basically if you do from import [press tab key] you get nothing. Even from torch.utils. [press tab key] still gives something unrelated torch.utils.backcompat torch.utils.hooks. So basically one cannot find that .data is a namespace inside torch.utils, so basically you cannot explore what exists in the library unless you’ve seen before an example code which loads a sampler from that namespace. Is there a better way to achieve this type of exploration when you’re looking around the library trying to figure out what exists there?


I believe autocompletion is IDE (and maybe IDE plugin) dependent…

Sometimes, when the autocompletion doesn’t work in my IDE for whatever reason, I use e.g. dir( to get the classes and methods.
Sometimes it doesn’t show all classes, but I have no idea why or how the namespaces are resolved internally.

@ptrblck @SimonW thanks for the replies guys but the examples I gave about where not from any IDE they were directly from python/ipython shell environment. If you simply drop into a python shell and do from import [tab key]. You won’t get any auto-completion. And if you don’t know that samples exists in the first place you’ll have a hard time finding them.

I get your point. But this is still an IDE feature. The Python IDE and iPython IDE are still IDEs. Many text editors don’t do autocompletion by default.

As @ptrblck mentioned, it could be a dir problem. If so, we should definitely fix it.

@SimonW thanks for the reply but i’m bit confused on the terminology here. For me python IDE means entirely something different from the python/ipython REPL. Are they the same thing?
If you invoke python on the terminal, you get:


that’s what I would call a REPL and not an IDE. So just to make sure that I’m making my point clear here is that all the above that I mentioned refer to the REPL. Don’t know if that makes any difference but just to clarify things up.


Hmm, that’s strage, since the autocompletion works in IPython (REPL).
Sometimes Spyder has some problems with loading the correct classes.

Here’s what I get on a python REPL:

Python 3.6.4 |Anaconda, Inc.| (default, Mar 13 2018, 01:15:57)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> from torch.utils.
torch.utils.backcompat  torch.utils.hooks

I don’t see the data namespace.

even if I do:

from import [tab key]

Returns no entries whatsoever.