Is there a point to import as both wildcard and non-wildcard manner like:
import spam as sp
from spam import *
in the very same file?<
import spam as sp
will load the module and put it into the variable sp
.
from spam import *
will load the module and all its attributes (classes, functions, etc...) and also the ones that are imported with a wildcard into spam
will be accessible.
import *
is a shortcut when you have a lot of classes, functions you need to access. But it is a bad practice (cf PEP) since you do not encapsulate imported attributes into a namespace (and it's what you do with import spam as sp
) and can lead to unwanted behavior (if 2 functions have the same name in your main program and into spam)
The best practice, and what states clearly what you'll use is from spam import func1, func2
or if you will use it a lot import spam as sp
and use sp.func1()