本文整理匯總了Python中hy.models.expression.HyExpression.pop方法的典型用法代碼示例。如果您正苦於以下問題:Python HyExpression.pop方法的具體用法?Python HyExpression.pop怎麽用?Python HyExpression.pop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類hy.models.expression.HyExpression
的用法示例。
在下文中一共展示了HyExpression.pop方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: for_macro
# 需要導入模塊: from hy.models.expression import HyExpression [as 別名]
# 或者: from hy.models.expression.HyExpression import pop [as 別名]
def for_macro(*tree):
ret = None
# for [x iter y iter] ...
# ->
# foreach x iter
# foreach y iter
# ...
tree = HyExpression(tree).replace(tree[0])
it = iter(tree.pop(0))
blocks = list(zip(it, it)) # List for Python 3.x degenerating.
key, val = blocks.pop(0)
ret = HyExpression([HySymbol("foreach"),
HyList([key, val])])
root = ret
ret.replace(tree)
for key, val in blocks:
# x, [1, 2, 3, 4]
nret = HyExpression([HySymbol("foreach"),
HyList([key, val])])
nret.replace(key)
ret.append(nret)
ret = nret
[ret.append(x) for x in tree] # we really need [email protected]
return root
示例2: router
# 需要導入模塊: from hy.models.expression import HyExpression [as 別名]
# 或者: from hy.models.expression.HyExpression import pop [as 別名]
def router(tree, rkwargs=None):
tree = HyExpression(tree)
name = tree.pop(0)
path = tree.pop(0)
tree.insert(0, HySymbol("fn"))
tree = HyExpression([HySymbol("def"), name, tree])
route = HyExpression([HySymbol(".route"), HySymbol("app"), path])
if rkwargs:
route = HyExpression([HySymbol("kwapply"), route,
HyDict({HyString("methods"): rkwargs})])
return HyExpression([HySymbol("with_decorator"), route, tree])