Method overloading?

Delaney, Timothy (Tim) tdelaney at avaya.com
Thu Feb 15 18:19:58 EST 2007


Steven D'Aprano wrote:

> This is an example of overloading:
> 
> class Cheese(object):
>     def flavour(self):
>         return "tasty and scrumptious"
>     def colour(self):
>         return "yellow"
> 
> Now we define a sub-class which overloads some methods:
> 
> class BlueVein(Cheese):
>     def colour(self):
>         return "white with blue veins"

Nope - while the term "overloading" is definitely overloaded, the above
is not an example of any use of "overloading".

It is an example of "overriding".

The most common use of "overloading" refers to having multiple methods
on a class with the same name, but different signatures.

Tim Delaney



More information about the Python-list mailing list