Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Python by (1.6k points)

What is the difference between abstract class and interface in Python?

1 Answer

0 votes
by (25.1k points)

Python only has Abstract Classes, and does not have Interfaces. Unlike a language like java that does not have multiple inheritance so it needs interfaces but python does have Multiple Inheritance so it does not need Interfaces.

You create an Abstract Class in Python like this:

class AbstractShape():

    def draw(self):

        raise NotImplementedError( "implemented this" )

Related questions

0 votes
1 answer
asked Oct 17, 2019 in Java by Shubham (3.9k points)
0 votes
1 answer
asked Sep 26, 2019 in Java by Shubham (3.9k points)
0 votes
1 answer

Browse Categories

...