+ 5

I still don't understand the difference between (import math) and (from math import *)

11th Jul 2016, 12:24 PM
G. keng
G. keng - avatar
3 ответов
+ 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)
11th Jul 2016, 12:44 PM
Gershon Fosu
Gershon Fosu - avatar
0
if you just import math you need to use math(.) to access their function
11th Jul 2016, 4:30 PM
Leo Feradero Nugraha
Leo Feradero Nugraha - avatar
- 11
no difference
11th Jul 2016, 3:15 PM
Evel Liu
Evel Liu - avatar