Basics

  • Different classes has same interface (i.e., method name), we can say that this group of related classes implement the same action
  • Being able to work with different types to call methods without checking it’s possible and handle errors using exception handling is called DOCK TYPING
  • Checking the type ahead of time is generally considered un-pythonic

An example from stackoverflow:

or an built in len method as an interface implemented by list and set object:

 

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。