What are all the ways to import modules in Python?

前端 未结 4 1578
陌清茗
陌清茗 2020-12-19 16:51

I\'ve done some research, and I came across the following article: http://effbot.org/zone/import-confusion.htm. While this seems to be a great guide, it was written in 1999,

4条回答
  •  悲哀的现实
    2020-12-19 17:39

    We can import modules in Python using the following ways

    • import module
    • from module import function
    • from module import *

    Although using from module import * is not a good practice, because of readability: Other programmer cannot understand what all are actually used in the current module. Memory overload: All are loaded in to memory. Best practices for using import in a module.

提交回复
热议问题