Python Polymorphism

infidel saint.infidel at gmail.com
Thu May 12 16:17:32 EDT 2005


carlos> Supose that I want to create two methos (inside a
carlos> class) with exactly same name, but number of
carlos> parameters different

That isn't polymorphism, that's function overloading.

carlos> Look, I don't want to use things like:
carlos>
carlos>       def myMethod(self, myValue=None):
carlos>            if(not myValue):
carlos>                 self.myAttribute += 1
carlos>            else:
carlos>                 self.myAttribute += myValue

Pick another language then.  Or try:

def myMethod(self, myValue=1):
    self.myAttribute += myValue




More information about the Python-list mailing list