Skip to content

Instantly share code, notes, and snippets.

@nhoad
Created June 20, 2014 06:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nhoad/d75714d2c0583feff439 to your computer and use it in GitHub Desktop.
Save nhoad/d75714d2c0583feff439 to your computer and use it in GitHub Desktop.
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