Created
June 20, 2014 06:30
-
-
Save nhoad/d75714d2c0583feff439 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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