def __getitem__(self, index): if isinstance(index, slice): indices = range(*index.indices(len(self))) return self._type( ns2Type(self.NS.objectAtIndex_(i) for i in indices)) else: return ns2Type(self.NS.objectAtIndex_(_at(self, index)))
def items(self): '''Yield the key, value pairs, like C{dict.items}. ''' for key, k in nsIter2(self.NS.allKeys()): v = self.NS.objectForKey_(k) if isNone(v): # missing key? self._NS_KeyError(key, k) yield key, ns2Type(v)
def _NS_get3(self, key): k = type2NS(key) v = self.NS.objectForKey_(k) # nil for missing key return k, v, (missing if isNone(v) else ns2Type(v))