Polymorphism the Python way
Daniel Klein
danielk at aracnet.com
Sat Aug 30 23:55:30 EDT 2003
Given the following code,,,
class Dead(object):
def __init__(self, adeadthing):
self.deadthing = adeadthing
def getthing(self):
return self.deadthing
class Parrot(object):
def __init__(self, aparrotthing):
self.parrotthing = aparrotthing
def getthing(self):
return self.parrotthing
...and then somewhere in some script I use...
self.getthing()
to get whatever 'thing' I want to get.
Isn't there a better way to do this in Python? I hate doing these
'get' type methods. The seem ugly to me.
Thanks,
Daniel Klein
More information about the Python-list
mailing list