c0dem0nkey-1000-keyboards c0dem0nkey-1000-keyboards - 9 months ago 65
Python Question

Autocomplete in Pydev / Eclipse is not showing all methods

I've been using Eclipse for many years now (for Java and Perl programming), but I've only recently installed PyDev as I want to use it as the IDE for learning Python.

My problem is that when I press the period sign after a variable name, the list of autocomplete suggestions does not show all the methods for that type.

E.g. In the screenshot below, I want to use the isoformat() method in the datetime module. If I manually type the variable.methodname i.e. end.isoformat(), the code is working fine.
However, while typing if I just press period after the variable End, the autocomplete suggestions dropdown does not contain isoformat anywhere. As you can see, datetime is in the list of Forced builtins, but that does not seem to help.

I have looked at other questions related to autocompletion problems for PyDev here on the site, but none of the solutions suggested in those threads are fixing my problem. As a beginner in Python, a working autocomplete would really be a lot of help for me. Can someone please help?

Details about my setup:

  • Eclipse Version: Luna Release (4.4.0) Build id: 20140612-0600

  • PyDev for Eclipse

  • Python 2.7.3

  • Windows 8.1

Edit: Bah, StackOverflow won't let me post a screenshot image because this is a new account and I have less than "10 reputation". What does preventing me from communicating more clearly using screenshots, have to do with experience points? Not cool on their part.

Anyway, I've pasted my code below:

import datetime

start = datetime.date(2014,7,7)
end = start + datetime.timedelta(days=180)

Answer Source

I think I figured out the answer.

I think that due to the dynamic nature of Python, in the code snippet above, the code editor does not know what type of object will be stored in the variable 'end', and so it does not know that it will be a date object, and hence does not show 'isoformat()' in the autocomplete suggestions.

When I type the variable 'start' and then a period, it does know that it is a date object, and it does show 'isoformat()' in the autocomplete suggestions.

So the autocomplete is working after all! That's a relief. :)