3 ms·
Here's my take: Don't use "import-star" in library code. Like you say, it obscures where elements of the namespace came from. When using Python interactively,
by dbieber 5y ago
Here's my take: Don't use "import-star" in library code. Like you say, it obscures where elements of the namespace came from.
When using Python interactively, esp. if the interactive session is to be thrown away at the end, then import-star can be fine and can be a good time-saver. Video editing is a great example of when this is appropriate. See also manim. Other examples might be one-off html parsing or one-off data manipulation tasks.
Similar to "import-star" is multiple inheritance. Just like import-star, multiple inheritance can make it ambiguous where methods come from, and imo it should similarly be avoided by default unless there's a compelling reason to use it.
- pbourke 5y agoI don’t import-star in the console or notebooks (PyCharm, specifically) because autocomplete works better with the module to scope the search. So I end up doing a lot of aliased imports like “import numpy as np”