Is it possible to import everything except one module from a package?
I need a lot of modules from a particular library that I use in my class, but it looks like it used the same module name for one of the modules that I need.
I need to use set operation and intersection, but when I import that library from my class, it gives me an error because of that.
I didn’t want to import it separately or put the name in front of every methods since I’m using it a lot.
Is there a way for the python to import everything except for a particular method like set?
Or maybe import the set part again later?
No, there is no terminology to
from ... import * except blah, bleh, bluh. You can either write your own import function to support it, or do something like:which will stop shadowing the built-in
setso you can use it again. Then if you need thexyz.setfunction you can do:Note:
from ... import *is not usually good practice, and you should make sure the modules you are using this way support it — if they don’t explicity say they were designed to be used this way, then you shouldn’t (unless you enjoy debugging weird problems later ;).