does python support overloaded methods?(py newbie)

Jason Orendorff jason at jorendorff.com
Mon Dec 31 13:11:46 EST 2001


karthik tamu wrote:
> 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.

Not possible or useful in Python, for your example anyway.

exchange_rates = { 'inr' : 0.020733,
                   'eur' : 0.890522,
                   'usd' : 1.000000 }

def calculate(amount, from_cur, to_cur):
    from_rate = exchange_rates[from_cur]
    to_rate = exchange_rates[to_cur]
    return amount * from_rate / to_rate

print calculate(1000, 'inr', 'usd')

## Jason Orendorff    http://www.jorendorff.com/




More information about the Python-list mailing list