Python module | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Python module

Just curiosity. I've imported all functions in random module using from random import * Now how can I delete all those functions at once ?

12th Feb 2020, 2:46 PM
Naveen K R
5 Answers
+ 1
If you use the * syntax, you import all the names one by one into your globals. So if you want to erase them from the globals, you'd have to use del on each one of them. If instead you imported random as one item (import random), you can just write: del random Out of curiosity: Why do you feel you need to do this?
12th Feb 2020, 2:58 PM
HonFu
HonFu - avatar
+ 1
HonFu I imported a module with * And finally realized I can't delete all functions at once btw thanks.
12th Feb 2020, 3:10 PM
Naveen K R
0
What do you mean by delete all the functions? As in remove them from your program because you don't want to use them anymore?
12th Feb 2020, 2:48 PM
XXX
XXX - avatar
0
Yup. I imported them in the python console. Used it and done with it. Now I wanna delete it.
12th Feb 2020, 2:50 PM
Naveen K R
0
I haven't tried it and I haven't even spent time reading the whole thing. But you can try this https://mail.python.org/pipermail/tutor/2006-August/048596.html
12th Feb 2020, 2:54 PM
XXX
XXX - avatar