user2192778 user2192778 - 1 year ago 82
Python Question

Are these statements equivalent?: import package vs from package import *

Are these statements equivalent?:

import math
from math import *

Answer Source

import math means that you have to put the math (name of the module) before everything you use from it, e.g. print(math.pi).

With using from math import *, Python is loading all functions and variables from math (or those specified in __all__ to be exact) into you local namespace and you can use them without module name prefix: print(pi).

Hope this helps!

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