Why does importing a python module not import nested modules?

后端 未结 5 2198
误落风尘
误落风尘 2020-12-10 04:37

If I do this:

import lxml 

in python, lxml.html is not imported. For instance, I cannot call the lxml.html.parse()

5条回答
  •  臣服心动
    2020-12-10 04:55

    This is to allow only the minimum amount of code to have to be loaded for multi-part libraries that you may not use the entirety of. For instance, you might not be using the html part of lxml, and thus not want to have to deal with loading its code.

提交回复
热议问题