Software Enthusiastic Software Enthusiastic - 1 year ago 118
Python Question

Why is "import *" bad?

It is recommended to not to use

import *
in Python.

Can anyone please share the reason for that, so that I can avoid it doing next time?

Answer Source
  • Because it puts a lot of stuff into your namespace (might shadow some other object from previous import and you won't know about it).

  • Because you don't know exactly what is imported and can't find place from what module certain thing was imported easily (readability).

  • Because you can't use cool tools like pyflakes to detect statically errors in your code.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download