Skip to content

Instantly share code, notes, and snippets.

@Bachmann1234
Last active August 29, 2015 14:09
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 Bachmann1234/0a4fe123f7936ec09c44 to your computer and use it in GitHub Desktop.
Save Bachmann1234/0a4fe123f7936ec09c44 to your computer and use it in GitHub Desktop.
Functools example. Create a basetwo function
[18, 91, 15]
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'])])
@jstnlef
Copy link

jstnlef commented Nov 17, 2014

Love partial ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment