views:

431

answers:

2

I'm noticing that even for system modules, code completion doesn't work too well.

For example, if I have a simple file that does:

import re
p = re.compile(pattern)
m = p.search(line)

If I type p., I don't get completion for methods I'd expect to see (I don't see search() for example, but I do see others, such as func_closure(), func_code()).

If I type m., I don't get any completion what so ever (I'd expect .groups(), in this case).

This doesn't seem to affect all modules.. Has any one seen this behaviour and knows how to correct it?

I'm running Vim 7.2 on WinXP, with the latest pythoncomplete.vim from vim.org (0.9), running python 2.6.2.

+2  A: 

Completion for this kind of things is tricky, because it would need to execute the actual code to work.

For example p.search() could return None or a MatchObject, depending on the data that is passed to it.

This is why omni-completion does not work here, and probably never will. It works for things that can be statically determined, for example a module's contents.

Luper Rouch
Doing the same kind of test in IDLE yields different completion depending on if there's a match or not, so your answer makes sense. Thanks.
jhp
A: 

I never got the builtin omnicomplete to work for any languages. I had the most success with pysmell (which seems to have been updated slightly more recently on github than in the official repo). I still didn't find it to be reliable enough to use consistently but I can't remember exactly why.

I've resorted to building an extensive set of snipMate snippets for my primary libraries and using the default tab completion to supplement.

Karl Guertin