import werkzeug VS from werkzeug import security
问题 My current understanding (based on these answers: one, two, three; and Python documentation) of how import in Python works is (just in case it matters: all the code snippets are tested on Python 3.6.1) : Say we have a module mod , which has submodules sub and sub1 ; sub , in turn, has a function func ; then we can (given that mod installed in current environment, of course): import mod mod.sub.func() mod.sub1 # or import mod.sub mod.sub.func() mod.sub1 # will result in "NameError: name 'mod'