Skip to content

Instantly share code, notes, and snippets.

@joshkunz
Created July 3, 2013 18:36
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 joshkunz/5921440 to your computer and use it in GitHub Desktop.
Save joshkunz/5921440 to your computer and use it in GitHub Desktop.
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