from abc import ABC, abstractmethod
class Example(ABC):
    def smile(self):
        print("smile")
My understanding is that Example becomes an AbstractClass when it inherits the ABC class. An AbstractClass can't be instantiated but
the following code executes without errors
example = Example()
                Your class does become abstract, although the method/methods that are contained inside (which is smile) is/are concrete. You need to make the methods inside abstract using the decorator @abc.abstractclass. Thus, if you rewrite your code to:
from abc import ABC, abstractmethod
class Example(ABC):
    @abstractmethod
    def smile(self):
        print("smile")
        
e = Example()
then you would get the error:
TypeError: Can't instantiate abstract class Example with abstract methods smile
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With