Q:

what is difference between "import module" and "from module import *"

I am new in python and trying to understand the difference between "import module" and "from module import *". I was thinking both are the same as they import all the functions from the module but doesn't see so. My confusion stems from the below code--
import abc
class Minnn(ABC):
    @abstractmethod
    def calculate(self, x):
        pass  # empty body, no c

When I run, I get the following error saying "NameError: name 'ABC' is not defined". When I replace the first import line with "from abc import *" then it works. So why is this causing a difference

A:

Importing a module adds a single symbol into the namespace, but from which you can reference exported objects:
# simple import
import abc

abc.ABC
abc.ABCMeta

# renamed via "as"
import abc as module
module.ABC
module.ABCMeta

When you import *, you are adding all exported symbols from that module into the current namespace, and so you can reference them directly without the module prefix:
#### YOU PROBABLY SHOULD NOT DO THIS
from abc import *
####

ABC
ABCMeta

If you're hacking in a shell or notebook; not a big deal. But production code should not do this.

