Skip to content

Instantly share code, notes, and snippets.

@nhoad

nhoad/output

Created Jun 20, 2014
Embed
What would you like to do?
from overload import overload
@overload
def hello(name: str):
print('Hello, %s!' % name)
@overload
def hello(name: int):
print('Hello, robot no. %d!' % name)
@overload
def hello(name: float):
print("I can't exactly work out your name... is %.2f close?" % name)
@overload
def hello(name: float, name2: str):
print("You have two names? One is a number, the other str?")
hello('bob')
hello(5)
hello(5.123412341234)
hello(5.123412341234, 'bob')
Hello, bob!
Hello, robot no. 5!
I can't exactly work out your name... is 5.12 close?
You have two names? One is a number, the other str?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment