我们从Python开源项目中,提取了以下27个代码示例,用于说明如何使用__builtin__.zip()。
def _get_conditional_content(self, fname, spans, conditions, contents): out = [] ieval = [] peval = [] multiline = (spans[0][0] != spans[-1][1]) for condition, content, span in zip(conditions, contents, spans): try: cond = bool(self._evaluate(condition, fname, span[0])) except Exception as exc: msg = "exception occured when evaluating '{0}'"\ .format(condition) raise FyppFatalError(msg, fname, span, exc) if cond: if self._linenums and not self._diverted and multiline: out.append(linenumdir(span[1], fname)) outcont, ievalcont, pevalcont = self._render(content) ieval += _shiftinds(ievalcont, len(out)) peval += pevalcont out += outcont break if self._linenums and not self._diverted and multiline: out.append(linenumdir(spans[-1][1], fname)) return out, ieval, peval
def oldzip(*args, **kwargs): return list(builtins.zip(*args, **kwargs))
def lzip(*args, **kwargs): return list(zip(*args, **kwargs))
def _get_iterated_content(self, fname, spans, loopvars, loopiter, content): out = [] ieval = [] peval = [] try: iterobj = iter(self._evaluate(loopiter, fname, spans[0][0])) except Exception as exc: msg = "exception occured when evaluating '{0}'"\ .format(loopiter) raise FyppFatalError(msg, fname, spans[0], exc) multiline = (spans[0][0] != spans[-1][1]) for var in iterobj: if len(loopvars) == 1: self._define(loopvars[0], var) else: for varname, value in zip(loopvars, var): self._define(varname, value) if self._linenums and not self._diverted and multiline: out.append(linenumdir(spans[0][1], fname)) outcont, ievalcont, pevalcont = self._render(content) ieval += _shiftinds(ievalcont, len(out)) peval += pevalcont out += outcont if self._linenums and not self._diverted and multiline: out.append(linenumdir(spans[1][1], fname)) return out, ieval, peval
def define(self, name, value): '''Define a Python entity. Args: name (str): Name of the entity. value (Python object): Value of the entity. Raises: FyppFatalError: If name starts with the reserved prefix or if it is a reserved name. ''' varnames = self._get_variable_names(name) if len(varnames) == 1: value = (value,) elif len(varnames) != len(value): msg = 'value for tuple assignment has incompatible length' raise FyppFatalError(msg) for varname, varvalue in zip(varnames, value): self._check_variable_name(varname) if self._locals is None: self._globals[varname] = varvalue else: if varname in self._globalrefs: self._globals[varname] = varvalue else: self._locals[varname] = varvalue self._scope[varname] = varvalue
def _argsplit_fortran(argtxt): txt = _INLINE_EVAL_REGION_REGEXP.sub(_blank_match, argtxt) splitpos = [-1] quote = None closing_brace_stack = [] closing_brace = None for ind, char in enumerate(txt): if quote: if char == quote: quote = None continue if char in _QUOTES_FORTRAN: quote = char continue if char in _OPENING_BRACKETS_FORTRAN: closing_brace_stack.append(closing_brace) ind = _OPENING_BRACKETS_FORTRAN.index(char) closing_brace = _CLOSING_BRACKETS_FORTRAN[ind] continue if char in _CLOSING_BRACKETS_FORTRAN: if char == closing_brace: closing_brace = closing_brace_stack.pop(-1) continue else: msg = "unexpected closing delimiter '{0}' in expression '{1}' "\ "at position {2}".format(char, argtxt, ind + 1) raise FyppFatalError(msg) if not closing_brace and char == _ARGUMENT_SPLIT_CHAR_FORTRAN: splitpos.append(ind) if quote or closing_brace: msg = "open quotes or brackets in expression '{0}'".format(argtxt) raise FyppFatalError(msg) splitpos.append(len(txt)) fragments = [argtxt[start + 1 : end] for start, end in zip(splitpos, splitpos[1:])] return fragments