Python Forum
Polymorphism in Python Question
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Polymorphism in Python Question
#3
There is no concept on interface in python. However you can define an abstract class. And you do this by inheriting from class called ABC. See the link bellow to know more about ABC.

https://docs.python.org/2/library/abc.html

class Animal(ABC):

    def __init__(self):
        super.__init__()

    @abstractmethod
    def sound(self):
        pass


class Dog(Animal):

    def __init__(self):
        pass

    def sound(self):
        return "Im dog"
Reply


Messages In This Thread
Polymorphism in Python Question - by Oliver - Dec-13-2017, 02:10 PM
RE: Polymorphism in Python Question - by mpd - Dec-13-2017, 02:20 PM
RE: Polymorphism in Python Question - by hshivaraj - Dec-13-2017, 02:37 PM
RE: Polymorphism in Python Question - by Oliver - Dec-13-2017, 03:36 PM
RE: Polymorphism in Python Question - by hshivaraj - Dec-13-2017, 04:06 PM
RE: Polymorphism in Python Question - by Oliver - Dec-13-2017, 08:26 PM
RE: Polymorphism in Python Question - by metulburr - Dec-13-2017, 04:08 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Polymorphism not working with a call to a abstract method colt 3 2,367 Nov-04-2019, 11:04 PM
Last Post: colt

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020