當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。