Last active
August 29, 2015 14:09
-
-
Save Bachmann1234/0a4fe123f7936ec09c44 to your computer and use it in GitHub Desktop.
Functools example. Create a basetwo function
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
[18, 91, 15] |
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 partial | |
basetwo = partial(int, base=2) | |
basetwo.__doc__ = 'Convert base 2 string to an int.' | |
print([result for result in map(basetwo, ['10010', '1011011', '1111'])]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Love partial ;)