+ 5
I still don't understand the difference between (import math) and (from math import *)
3 Answers
+ 16
(from module import method) allows you call a method without prefixing it with the module name. So when you use (from module import *) to import all the functions in the module, you can access them without prefixing them. E.g
from random import *
randint (1,10) //I can call without prefixing with random
import random //I would need to prefix the function I call with the module name
E.g.
random.randint (1,10)
0
if you just import math you need to use math(.) to access their function
- 11
no difference