def __iter__(self): """ Magic method for in. """ for rod_ in self._rods: rod__ = methods.decompress_rod(rod_) yield rod__
def _get_rod(self): """ Returns the first rod in the queue """ rod_ = self._rods.get() self._rods.put(methods.decompress_rod(rod_)) return rod_
def __getitem__(self, rod_id): """ Magic method for []. """ self.fill_dicts() try: return methods.decompress_rod(self._rods_dict[rod_id]) except KeyError: msg = str(rod_id) msg += " " + str(self._rods_dict.keys()) raise IndexError(msg)
def __list__(self): """ Returns a list of rods """ output = [methods.decompress_rod(rod_) for rod_ in self] return output