當前位置: 首頁>>代碼示例>>Python>>正文


Python a.foo方法代碼示例

本文整理匯總了Python中x.a.foo方法的典型用法代碼示例。如果您正苦於以下問題:Python a.foo方法的具體用法?Python a.foo怎麽用?Python a.foo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在x.a的用法示例。


在下文中一共展示了a.foo方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_tuple_unpack

# 需要導入模塊: from x import a [as 別名]
# 或者: from x.a import foo [as 別名]
def test_tuple_unpack(self):
        b = """
            def foo():
                try:
                    pass
                except Exception, (f, e):
                    pass
                except ImportError, e:
                    pass"""

        a = """
            def foo():
                try:
                    pass
                except Exception as xxx_todo_changeme:
                    (f, e) = xxx_todo_changeme.args
                    pass
                except ImportError as e:
                    pass"""
        self.check(b, a) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:22,代碼來源:test_fixers.py

示例2: test_remove_multiple_items

# 需要導入模塊: from x import a [as 別名]
# 或者: from x.a import foo [as 別名]
def test_remove_multiple_items(self):
        b = """isinstance(x, (int, int, int))"""
        a = """isinstance(x, int)"""
        self.check(b, a)

        b = """isinstance(x, (int, float, int, int, float))"""
        a = """isinstance(x, (int, float))"""
        self.check(b, a)

        b = """isinstance(x, (int, float, int, int, float, str))"""
        a = """isinstance(x, (int, float, str))"""
        self.check(b, a)

        b = """isinstance(foo() + bar(), (x(), y(), x(), int, int))"""
        a = """isinstance(foo() + bar(), (x(), y(), x(), int))"""
        self.check(b, a) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:18,代碼來源:test_fixers.py

示例3: test_wrap_in_list

# 需要導入模塊: from x import a [as 別名]
# 或者: from x.a import foo [as 別名]
def test_wrap_in_list(self):
        b = """x = range(10, 3, 9)"""
        a = """x = list(range(10, 3, 9))"""
        self.check(b, a)

        b = """x = foo(range(10, 3, 9))"""
        a = """x = foo(list(range(10, 3, 9)))"""
        self.check(b, a)

        b = """x = range(10, 3, 9) + [4]"""
        a = """x = list(range(10, 3, 9)) + [4]"""
        self.check(b, a)

        b = """x = range(10)[::-1]"""
        a = """x = list(range(10))[::-1]"""
        self.check(b, a)

        b = """x = range(10)  [3]"""
        a = """x = list(range(10))  [3]"""
        self.check(b, a) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:22,代碼來源:test_fixers.py

示例4: test_import_from

# 需要導入模塊: from x import a [as 別名]
# 或者: from x.a import foo [as 別名]
def test_import_from(self):
        for old, changes in self.modules.items():
            all_members = []
            for new, members in changes:
                for member in members:
                    all_members.append(member)
                    b = "from %s import %s" % (old, member)
                    a = "from %s import %s" % (new, member)
                    self.check(b, a)

                    s = "from foo import %s" % member
                    self.unchanged(s)

                b = "from %s import %s" % (old, ", ".join(members))
                a = "from %s import %s" % (new, ", ".join(members))
                self.check(b, a)

                s = "from foo import %s" % ", ".join(members)
                self.unchanged(s)

            # test the breaking of a module into multiple replacements
            b = "from %s import %s" % (old, ", ".join(all_members))
            a = "\n".join(["from %s import %s" % (new, ", ".join(members))
                            for (new, members) in changes])
            self.check(b, a) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:27,代碼來源:test_fixers.py

示例5: test_indented

# 需要導入模塊: from x import a [as 別名]
# 或者: from x.a import foo [as 別名]
def test_indented(self):
        b = """
def foo():
    from urllib import urlencode, urlopen
"""
        a = """
def foo():
    from urllib.parse import urlencode
    from urllib.request import urlopen
"""
        self.check(b, a)

        b = """
def foo():
    other()
    from urllib import urlencode, urlopen
"""
        a = """
def foo():
    other()
    from urllib.parse import urlencode
    from urllib.request import urlopen
"""
        self.check(b, a) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:26,代碼來源:test_fixers.py

示例6: test_import_module_usage

# 需要導入模塊: from x import a [as 別名]
# 或者: from x.a import foo [as 別名]
def test_import_module_usage(self):
        for old, changes in self.modules.items():
            for new, members in changes:
                for member in members:
                    new_import = ", ".join([n for (n, mems)
                                            in self.modules[old]])
                    b = """
                        import %s
                        foo(%s.%s)
                        """ % (old, old, member)
                    a = """
                        import %s
                        foo(%s.%s)
                        """ % (new_import, new, member)
                    self.check(b, a)
                    b = """
                        import %s
                        %s.%s(%s.%s)
                        """ % (old, old, member, old, member)
                    a = """
                        import %s
                        %s.%s(%s.%s)
                        """ % (new_import, new, member, new, member)
                    self.check(b, a) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:26,代碼來源:test_fixers.py

示例7: test_prefix_preservation_4

# 需要導入模塊: from x import a [as 別名]
# 或者: from x.a import foo [as 別名]
def test_prefix_preservation_4(self):
        b = """
            next = 5
            for a in b:
                foo(a) # abc
                # def
                a.next()
            """
        a = """
            next = 5
            for a in b:
                foo(a) # abc
                # def
                a.__next__()
            """
        self.check(b, a, ignore_warnings=True) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:18,代碼來源:test_fixers.py

示例8: test_method_4

# 需要導入模塊: from x import a [as 別名]
# 或者: from x.a import foo [as 別名]
def test_method_4(self):
        b = """
            class A:
                def __init__(self, foo):
                    self.foo = foo

                def next(self):
                    pass

                def __iter__(self):
                    return self
            """
        a = """
            class A:
                def __init__(self, foo):
                    self.foo = foo

                def __next__(self):
                    pass

                def __iter__(self):
                    return self
            """
        self.check(b, a) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:26,代碼來源:test_fixers.py

示例9: test_while

# 需要導入模塊: from x import a [as 別名]
# 或者: from x.a import foo [as 別名]
def test_while(self):
        b = """while 1: foo()"""
        a = """while True: foo()"""
        self.check(b, a)

        b = """while   1: foo()"""
        a = """while   True: foo()"""
        self.check(b, a)

        b = """
            while 1:
                foo()
            """
        a = """
            while True:
                foo()
            """
        self.check(b, a) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:20,代碼來源:test_fixers.py

示例10: test_weird_comments

# 需要導入模塊: from x import a [as 別名]
# 或者: from x.a import foo [as 別名]
def test_weird_comments(self):
        b = """apply(   # foo
          f, # bar
          args)"""
        a = """f(*args)"""
        self.check(b, a)

    # These should *not* be touched 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:10,代碼來源:test_fixers.py

示例11: test_weird_target_2

# 需要導入模塊: from x import a [as 別名]
# 或者: from x.a import foo [as 別名]
def test_weird_target_2(self):
        b = """
            try:
                pass
            except Exception, a.foo:
                pass"""

        a = """
            try:
                pass
            except Exception as xxx_todo_changeme:
                a.foo = xxx_todo_changeme
                pass"""
        self.check(b, a) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:16,代碼來源:test_fixers.py

示例12: test_weird_target_3

# 需要導入模塊: from x import a [as 別名]
# 或者: from x.a import foo [as 別名]
def test_weird_target_3(self):
        b = """
            try:
                pass
            except Exception, a().foo:
                pass"""

        a = """
            try:
                pass
            except Exception as xxx_todo_changeme:
                a().foo = xxx_todo_changeme
                pass"""
        self.check(b, a) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:16,代碼來源:test_fixers.py

示例13: test_with_comments

# 需要導入模塊: from x import a [as 別名]
# 或者: from x.a import foo [as 別名]
def test_with_comments(self):
        b = """raise Exception, 5 # foo"""
        a = """raise Exception(5) # foo"""
        self.check(b, a)

        b = """raise E, (5, 6) % (a, b) # foo"""
        a = """raise E((5, 6) % (a, b)) # foo"""
        self.check(b, a)

        b = """def foo():
                    raise Exception, 5, 6 # foo"""
        a = """def foo():
                    raise Exception(5).with_traceback(6) # foo"""
        self.check(b, a) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:16,代碼來源:test_fixers.py

示例14: test_string_exc_val

# 需要導入模塊: from x import a [as 別名]
# 或者: from x.a import foo [as 別名]
def test_string_exc_val(self):
        s = """raise "foo", 5"""
        self.warns_unchanged(s, "Python 3 does not support string exceptions") 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:5,代碼來源:test_fixers.py

示例15: test_string_exc_val_tb

# 需要導入模塊: from x import a [as 別名]
# 或者: from x.a import foo [as 別名]
def test_string_exc_val_tb(self):
        s = """raise "foo", 5, 6"""
        self.warns_unchanged(s, "Python 3 does not support string exceptions")

    # These should result in traceback-assignment 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:7,代碼來源:test_fixers.py


注:本文中的x.a.foo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。