Scott Scott - 2 months ago 14
Python Question

Using lxml in an IDE with code completion/auto complete

I'm trying to use lxml in pycharm or eclipse using pydev, everything is working correctly except for code completion, it seems to be non-existant. Is there something I need to implement to get it to work with the classes from lxml?

For example:

import lxml.html
html = open('html.html', 'r').read()

root = lxml.html.fromstring(html)
tds = root.cssselect("")

print temp[0].text # I know that the text attribute exists but code completion doesn't show it

Note: Intelisense and smart help work for other things just not lxml.


This is usually a problem with modules written in C like lxml, where most parsers can only get the signature of a method but not the details. The signature of a python method doesn't have the return type so it's hard to guess the type of tds. This lack of information leads to the failure of the auto-complete feature.

Other than waiting for the IDEs' authors for improve their parsers, there's not much that you can do.