Should I use numpy (or pylab) as a python environment by using `from numpy import *`?

前端 未结 5 1571
一个人的身影
一个人的身影 2021-01-04 08:32

I use pylab (more specifically numpy) in all of my python programs­. The exceptions are very rare, if any. So far, I have taken the habit of importing numpy in the following

5条回答
  •  猫巷女王i
    2021-01-04 09:26

    it is not a significant problem if numpy is the only module you import like this. Never EVER import any other modules like this in your scripts (unless that module was written by you and you know everything about it and it is reasonably small. For instance, sometimes you split a module into two files so that you can compartmentalize better).

    General Rule: Your code readability will not suffer significantly by importing widely used modules (such as numpy) in this manner. But never never import more than one.

    My Rule: I NEVER do this kind of import. I always do something like "import numpy as np" if it is going to be used alot.

提交回复
热议问题