当前位置: 首页>>代码示例>>Python>>正文


Python fixer_util.commatize方法代码示例

本文整理汇总了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 
开发者ID:remg427,项目名称:misp42splunk,代码行数:20,代码来源:fix_unpacking.py

示例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 
开发者ID:remg427,项目名称:misp42splunk,代码行数:15,代码来源:fix_unpacking.py


注:本文中的libfuturize.fixer_util.commatize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。