def __getitem__( self, i: typing.Union[int, slice] ) -> typing.Union['StrSexpVector', str, 'na_values.NA_Character']: cdata = self.__sexp__._cdata if isinstance(i, int): i_c = _rinterface._python_index_to_c(cdata, i) res = _rinterface._string_getitem(cdata, i_c) if res is None: res = na_values.NA_Character elif isinstance(i, slice): res = self.from_iterable([ _rinterface._string_getitem(cdata, i_c) for i_c in range(*i.indices(len(self))) ]) else: raise TypeError('Indices must be integers or slices,' ' not %s' % type(i)) return res
def keys(self) -> typing.Generator[str, None, None]: """Generator over the keys (symbols) in the environment.""" with memorymanagement.rmemory() as rmemory: symbols = rmemory.protect( openrlib.rlib.R_lsInternal(self.__sexp__._cdata, openrlib.rlib.TRUE)) n = openrlib.rlib.Rf_xlength(symbols) res = [] for i in range(n): res.append(_rinterface._string_getitem(symbols, i)) for e in res: yield e
def keys(self) -> typing.Generator[str, None, None]: """Generator over the keys (symbols) in the environment.""" with memorymanagement.rmemory() as rmemory: symbols = rmemory.protect( openrlib.rlib.R_lsInternal(self.__sexp__._cdata, openrlib.rlib.TRUE)) n = openrlib.rlib.Rf_xlength(symbols) res = [] for i in range(n): _ = _rinterface._string_getitem(symbols, i) if _ is None: raise TypeError( 'R symbol string should not be able to be NA.') res.append(_) for e in res: yield e