Last active
November 3, 2017 23:34
-
-
Save juanarrivillaga/883029c6c01648f4017e5a658b96cd77 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
def numin_er(srch_string): | |
def inner(mem): | |
return srch_string.count(mem) | |
return inner | |
sublist = ('x', 'str', 'a', 'pr') | |
string = "rprpraxp" | |
result = sum(map(numin_er(string), sublist)) | |
# although, in this case, you can just pass the | |
# bound method! | |
result = sum(map(string.count, sublist)) | |
# overall point: functions are just like any other object | |
# methods are function objects that carry around the state | |
# from the object they are bound to. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment