Skip to content

Instantly share code, notes, and snippets.

@emberian
Created July 6, 2012 21:08
Show Gist options
  • Save emberian/3062755 to your computer and use it in GitHub Desktop.
Save emberian/3062755 to your computer and use it in GitHub Desktop.
Example Room container for martianman
class Room(object):
def __init__(self):
self._container = set()
def __contains__(self, item):
return self._container.__contains__(item)
def add(self, item):
self._container.add(item)
item.room.remove(item)
item.room = self
def remove(self, item):
if item in self:
self._container.dispose(item)
item.room = None
def contents(self):
return list(self._container)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment