本文整理汇总了Python中libfuturize.fixer_util.commatize方法的典型用法代码示例。如果您正苦于以下问题:Python fixer_util.commatize方法的具体用法?Python fixer_util.commatize怎么用?Python fixer_util.commatize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类libfuturize.fixer_util
的用法示例。
在下文中一共展示了fixer_util.commatize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fix_implicit_context
# 需要导入模块: from libfuturize import fixer_util [as 别名]
# 或者: from libfuturize.fixer_util import commatize [as 别名]
def fix_implicit_context(self, node, results):
u"""
Only example of the implicit context is
a for loop, so only fix that.
"""
pre, name, post, it = (results.get(n) for n in (u"pre", u"name", u"post", u"it"))
pre = [n.clone() for n in pre if n.type == token.NAME]
name.prefix = u" "
post = [n.clone() for n in post if n.type == token.NAME]
target = [n.clone() for n in commatize(pre + [name.clone()] + post)]
# to make the special-case fix for "*z, = ..." correct with the least
# amount of modification, make the left-side into a guaranteed tuple
target.append(Comma())
source = it.clone()
source.prefix = u""
setup_line = Assign(Name(self.LISTNAME), Call(Name(u"list"), [Name(self.ITERNAME)]))
power_line = Assign(target, assignment_source(len(pre), len(post), self.LISTNAME, self.ITERNAME))
return setup_line, power_line
示例2: fix_explicit_context
# 需要导入模块: from libfuturize import fixer_util [as 别名]
# 或者: from libfuturize.fixer_util import commatize [as 别名]
def fix_explicit_context(self, node, results):
pre, name, post, source = (results.get(n) for n in (u"pre", u"name", u"post", u"source"))
pre = [n.clone() for n in pre if n.type == token.NAME]
name.prefix = u" "
post = [n.clone() for n in post if n.type == token.NAME]
target = [n.clone() for n in commatize(pre + [name.clone()] + post)]
# to make the special-case fix for "*z, = ..." correct with the least
# amount of modification, make the left-side into a guaranteed tuple
target.append(Comma())
source.prefix = u""
setup_line = Assign(Name(self.LISTNAME), Call(Name(u"list"), [source.clone()]))
power_line = Assign(target, assignment_source(len(pre), len(post), self.LISTNAME, self.ITERNAME))
return setup_line, power_line