When you import
from a module, only the names that you specify are bound in the importing scope, but all of the top level code in that module is executed.
This is important because some of the names that you import might depend on code that you didn't explicitly import -- for example, that module's own imports, the definitions of private functions/classes/objects that the exported functions depend on, etc! It would be extremely unwieldy if you had to understand all of the dependencies of the module you're importing and explicitly import each dependency to make sure that the things you're actually trying to use will work correctly.
Needless to say, you should not have top-level module code that you don't want to get executed on every import. This is why you'll often see blocks in scripts like:
if __name__ == '__main__':
# actually do stuff
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…