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?<
No. Since you have imported spam
with name sp
and then imported everything using from spam import *
sp
will never be used and is therefore unnecessary.
For example if we have a function called somefunction()
. import spam as sp
would mean we could call somefunction()
with sp.somefunction()
Since from spam import *
it can be called directly somefunction()
so why use sp.somefunction()
instead.
from spam import *
is considered extremely bad practice. You should import each function individually rather than do that. (from spam import somefunction
, from spam import someotherfunction
and so on). Or you could just use sp.somefunction()
, sp.someotherfunction()
.