本文整理匯總了Python中a.b.c方法的典型用法代碼示例。如果您正苦於以下問題:Python b.c方法的具體用法?Python b.c怎麽用?Python b.c使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類a.b
的用法示例。
在下文中一共展示了b.c方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _pop_import_LOAD_ATTRs
# 需要導入模塊: from a import b [as 別名]
# 或者: from a.b import c [as 別名]
def _pop_import_LOAD_ATTRs(module_name, queue):
"""
Pop LOAD_ATTR instructions for an import of the form::
import a.b.c as d
which should generate bytecode like this::
1 0 LOAD_CONST 0 (0)
3 LOAD_CONST 1 (None)
6 IMPORT_NAME 0 (a.b.c.d)
9 LOAD_ATTR 1 (b)
12 LOAD_ATTR 2 (c)
15 LOAD_ATTR 3 (d)
18 STORE_NAME 3 (d)
"""
popped = popwhile(is_a(instrs.LOAD_ATTR), queue, side='left')
if popped:
expected = module_name.split('.', maxsplit=1)[1]
actual = '.'.join(map(op.attrgetter('arg'), popped))
if expected != actual:
raise DecompilationError(
"Decompiling import of module %s, but LOAD_ATTRS imply %s" % (
expected, actual,
)
)
return popped
示例2: _make_expr_empty_dict
# 需要導入模塊: from a import b [as 別名]
# 或者: from a.b import c [as 別名]
def _make_expr_empty_dict(toplevel, stack_builders):
"""
This should only be hit for empty dicts. Anything else should hit the
STORE_MAP handler instead.
"""
if toplevel.arg:
raise DecompilationError(
"make_expr() called with nonzero BUILD_MAP arg %d" % toplevel.arg
)
if stack_builders:
raise DecompilationError(
"Unexpected stack_builders for BUILD_MAP(0): %s" % stack_builders
)
return ast.Dict(keys=[], values=[])
示例3: make_slice_tuple
# 需要導入模塊: from a import b [as 別名]
# 或者: from a.b import c [as 別名]
def make_slice_tuple(toplevel, stack_builders):
slice_ = _make_expr(toplevel, stack_builders)
if isinstance(slice_, ast.Tuple):
# a = b[c, d] generates Index(value=Tuple(...))
# a = b[c:, d] generates ExtSlice(dims=[Slice(...), Index(...)])
slice_ = normalize_tuple_slice(slice_)
return slice_
示例4: spam
# 需要導入模塊: from a import b [as 別名]
# 或者: from a.b import c [as 別名]
def spam(a, b, c): pass
示例5: popwhile
# 需要導入模塊: from a import b [as 別名]
# 或者: from a.b import c [as 別名]
def popwhile(cond, queue, *, side):
"""
Pop elements off a queue while `cond(nextelem)` is True.
Parameters
----------
cond : predicate
queue : deque
side : {'left', 'right'}
Returns
-------
popped : deque
Examples
--------
>>> from collections import deque
>>> d = deque([1, 2, 3, 2, 1])
>>> popwhile(lambda x: x < 3, d, side='left')
deque([1, 2])
>>> d
deque([3, 2, 1])
>>> popwhile(lambda x: x < 3, d, side='right')
deque([2, 1])
>>> d
deque([3])
"""
if side not in ('left', 'right'):
raise ValueError("`side` must be one of 'left' or 'right'")
out = deque()
if side == 'left':
popnext = queue.popleft
pushnext = out.append
nextidx = 0
else:
popnext = queue.pop
pushnext = out.appendleft
nextidx = -1
while queue:
if not cond(queue[nextidx]):
break
pushnext(popnext())
return out