Import module and from module import* | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 7

Import module and from module import*

What are the diffrences between import module and from module import *

11th Jun 2020, 12:52 PM
Alireza
2 Answers
+ 7
import random (as an example) creates *one* name in your globals: random. Now you have to write random in front of everything you use from random. print(random.randint(1, 10)) from random import * ... on the other hand imports the names from the module. Then you can directly write: print(randint(1, 10))
11th Jun 2020, 1:13 PM
HonFu
HonFu - avatar
+ 5
𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥, being mod has no relation to knowing more about Python. ;-)
11th Jun 2020, 2:39 PM
HonFu
HonFu - avatar