Created
July 6, 2012 21:08
-
-
Save emberian/3062755 to your computer and use it in GitHub Desktop.
Example Room container for martianman
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 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