Created
October 19, 2017 14:18
-
-
Save tswann/6557bf0725f6baaeadf92c5a04c34811 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 functools import singledispatch | |
@singledispatch | |
def myfunction(obj): | |
print(‘Do something generic: {}’.format(obj)) | |
@myfunction.register(int) | |
def _(num): | |
print(‘Do something octal: {0:o}’.format(num)) | |
@myfunction.register(float) | |
def _(num): | |
print(‘Do something floaty: {0:.2f}’.format(num)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment