Created
July 3, 2013 18:36
-
-
Save joshkunz/5921440 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
class Person(object): | |
def __init__(self, name, *attrs): | |
self.name = name | |
self.attrs = set() | |
self.can(*attrs) | |
def does(self, what): | |
if what in self.attrs: return True | |
return False | |
def can(self, *what): | |
self.attrs |= set(what) | |
people = set([ | |
Person("Max", "surf", "swim"), | |
Person("Charlie", "dig", "fly") | |
]) | |
surfers = filter(lambda x: x.does("surf"), people) | |
assert surfers.pop().name == "Max" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment