python - "from math import sqrt" works but "import math" does not work. What is the reason? -


i pretty new in programming, learning python.

i'm using komodo edit 9.0 write codes. so, when write "from math import sqrt", can use "sqrt" function without problem. if write "import math", "sqrt" function of module doesn't work. reason behind this? can fix somehow?

you have 2 options:

import math math.sqrt() 

will import math module own namespace. means function names have prefixed math. practice because avoids conflicts , won't overwrite function imported current namespace.

alternatively:

from math import * sqrt() 

will import math module current namespace. that can problematic.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -