does python support overloaded methods?(py newbie)

karthik_tamu karthik_guru at rediffmail.com
Mon Dec 31 11:52:16 EST 2001


wanted to confirm this. Overloading method names(with parameters 
belonging to different types) is possible in python??.
from what i can see it should not be possible.
so if i have some currency conversion code like this:


class Currency:
	pass
class Dollar(Currency):
	pass
class Euro(Currency):
	pass

class CalculateRupeeEquivalent:
	def calculate(currency):
		//type checking of curency here?
		//i don't like it with lots of ifs and else.

so alternative is...

class CalculateRupeeEquivalentForDollar(CalculateRupeeEquivalent):
	def calculate(currency):
		//return equivalent


class CalculateRupeeEquivalentForEuro(CalculateRupeeEquivalent):
	def calculate(currency):
		//return equivalent


if __name__ == '__main__':
	calc = a.GetCalculator()
	curr = a.GetCurrency()
	calc.calculate(curr)

??

i read a nice article today

http://www.cyberdyne-object-sys.com/oofaq2/DynamicDispatch.htm

does python support dynamic dispatch then?

thanks,
karthik.







More information about the Python-list mailing list