In some cases, automatic Eclipse pydev clauses do not work

My question is probably stupid, and I hope someone managed to solve this problem.

Sometimes I don’t see the right sentences in the autocomplete window (Eclipse 3.5.2, PyDev 1.5.7). For example:

import email fp = open('my.eml', 'rb') msg = email.message_from_file(fp) 

msg now a Message object. And functions like get_payload () work fine.

 msg.get_payload() 

But I do not get get_payload() in the autocomplete list.

I think PyDev does not know what msg , so it does not know what to show.

Perhaps I need to import something else, not just the email module?

Thanks in advance!

+7
python eclipse autocomplete pydev
source share
3 answers

Most likely, the current PyDev assembly has not reached the point to be able to extract from the function ( message_from_file() in your case) to find out what type of object it returns to give an autocomplete hint.

See http://sourceforge.net/projects/pydev/forums/forum/293649/topic/3697707 .

Edit: I believe PyDev is interested in supporting the new Python 3 function syntax, PEP 3107 , which will solve some of your problems ... in the future.

+3
source share

I struggled with this issue too much until I came across this link . I used the second solution suggested in this link and it works like a charm.

Basically you need to insert assert isinstance(msg, Message) after you get msg from the function call.

+4
source share

I know that @type in docstring works. How in:

 from collections import deque def foo(a): ''' code completion sample @type a: deque ''' return a.popleft() # Code completion will work here 

I was not able to find a way to do this inside the code (unless you just pretend to assign a variable to an instance of the type), as in:

 from collections import deque def foo(a): ''' code completion sample ''' if false: a = deque() return a.popleft() # Code completion will also work here 

But I do not like this method, because it probably imposes a penalty for performance / code size. I do not know / did not check if Python is sufficient enough to remove this destination at compile time.

Thanks to SiSoie, here is a link to a page explaining the possibilities.

+1
source share

All Articles