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


Python a.b方法代碼示例

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


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

示例1: test_import_from_custom

# 需要導入模塊: import a [as 別名]
# 或者: from a import b [as 別名]
def test_import_from_custom(self):
        import __builtin__
        try:
            class foo(object):
                b = 'abc'
            def __import__(name, globals, locals, fromlist):
                global received
                received = name, fromlist
                return foo()
        
            saved = __builtin__.__import__
            __builtin__.__import__ = __import__
        
            from a import b
            self.assertEqual(received, ('a', ('b', )))
        finally:
            __builtin__.__import__ = saved 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:19,代碼來源:test_imp.py

示例2: test_import_from_custom

# 需要導入模塊: import a [as 別名]
# 或者: from a import b [as 別名]
def test_import_from_custom(self):
        import builtins
        try:
            class foo(object):
                b = 'abc'
            def __import__(name, globals, locals, fromlist, level):
                global received
                received = name, fromlist
                return foo()

            saved = builtins.__import__
            builtins.__import__ = __import__

            from a import b
            self.assertEqual(received, ('a', ('b', )))
        finally:
            builtins.__import__ = saved 
開發者ID:IronLanguages,項目名稱:ironpython3,代碼行數:19,代碼來源:test_imp.py

示例3: test_size_if_else

# 需要導入模塊: import a [as 別名]
# 或者: from a import b [as 別名]
def test_size_if_else():
    example = """
@identity
class Foo(object):
    @identity
    @identity
    def bar(self):
        if "a" == "b":
            pass
        elif "b" == "c":
            pass
        else:
            pass
"""
    size = 11
    check_size(example, size) 
開發者ID:jendrikseipp,項目名稱:vulture,代碼行數:18,代碼來源:test_size.py

示例4: test_dotted

# 需要導入模塊: import a [as 別名]
# 或者: from a import b [as 別名]
def test_dotted(self):
        self.assertEqual(self.parse("""
      import a.b
    """), [parsepy.ImportStatement(name='a.b')]) 
開發者ID:google,項目名稱:importlab,代碼行數:6,代碼來源:test_parsepy.py

示例5: test_as

# 需要導入模塊: import a [as 別名]
# 或者: from a import b [as 別名]
def test_as(self):
        self.assertEqual(self.parse("""
      import a as b
    """), [parsepy.ImportStatement(name='a', new_name='b')]) 
開發者ID:google,項目名稱:importlab,代碼行數:6,代碼來源:test_parsepy.py

示例6: test_dotted_as

# 需要導入模塊: import a [as 別名]
# 或者: from a import b [as 別名]
def test_dotted_as(self):
        self.assertEqual(self.parse("""
      import a.b as c
    """), [parsepy.ImportStatement(name='a.b', new_name='c')]) 
開發者ID:google,項目名稱:importlab,代碼行數:6,代碼來源:test_parsepy.py

示例7: test_dotted_comma

# 需要導入模塊: import a [as 別名]
# 或者: from a import b [as 別名]
def test_dotted_comma(self):
        self.assertEqual(self.parse("""
      import a.b, c
    """), [parsepy.ImportStatement(name='a.b'),
           parsepy.ImportStatement(name='c')]) 
開發者ID:google,項目名稱:importlab,代碼行數:7,代碼來源:test_parsepy.py

示例8: test_multiple_1

# 需要導入模塊: import a [as 別名]
# 或者: from a import b [as 別名]
def test_multiple_1(self):
        self.assertEqual(self.parse("""
      import a, b, c, d
    """), [parsepy.ImportStatement(name='a'),
           parsepy.ImportStatement(name='b'),
           parsepy.ImportStatement(name='c'),
           parsepy.ImportStatement(name='d')]) 
開發者ID:google,項目名稱:importlab,代碼行數:9,代碼來源:test_parsepy.py

示例9: test_multiple_3

# 需要導入模塊: import a [as 別名]
# 或者: from a import b [as 別名]
def test_multiple_3(self):
        self.assertEqual(self.parse("""
      import a, b as bb, a.x, a.x.y as a_x_y
    """), [parsepy.ImportStatement(name='a'),
           parsepy.ImportStatement(name='b', new_name='bb'),
           parsepy.ImportStatement(name='a.x', new_name='a.x'),
           parsepy.ImportStatement(name='a.x.y', new_name='a_x_y'),
           ]) 
開發者ID:google,項目名稱:importlab,代碼行數:10,代碼來源:test_parsepy.py

示例10: test_multiple_4

# 需要導入模塊: import a [as 別名]
# 或者: from a import b [as 別名]
def test_multiple_4(self):
        self.assertEqual(self.parse("""
      import a
      import b
      import c
      import d
    """), [parsepy.ImportStatement(name='a'),
           parsepy.ImportStatement(name='b'),
           parsepy.ImportStatement(name='c'),
           parsepy.ImportStatement(name='d')]) 
開發者ID:google,項目名稱:importlab,代碼行數:12,代碼來源:test_parsepy.py

示例11: test_from

# 需要導入模塊: import a [as 別名]
# 或者: from a import b [as 別名]
def test_from(self):
        self.assertEqual(self.parse("""
      from a import b
    """), [parsepy.ImportStatement(name='a.b', new_name='b', is_from=True)]) 
開發者ID:google,項目名稱:importlab,代碼行數:6,代碼來源:test_parsepy.py

示例12: test_from_with_rename

# 需要導入模塊: import a [as 別名]
# 或者: from a import b [as 別名]
def test_from_with_rename(self):
        self.assertEqual(self.parse("""
      from a import b as c
    """), [parsepy.ImportStatement(name='a.b', new_name='c', is_from=True)]) 
開發者ID:google,項目名稱:importlab,代碼行數:6,代碼來源:test_parsepy.py

示例13: test_dotted_from

# 需要導入模塊: import a [as 別名]
# 或者: from a import b [as 別名]
def test_dotted_from(self):
        self.assertEqual(self.parse("""
      from a.b.c import d as e
    """), [parsepy.ImportStatement(name='a.b.c.d', new_name='e', is_from=True)]) 
開發者ID:google,項目名稱:importlab,代碼行數:6,代碼來源:test_parsepy.py

示例14: test_from_parentheses

# 需要導入模塊: import a [as 別名]
# 或者: from a import b [as 別名]
def test_from_parentheses(self):
        self.assertEqual(self.parse("""
      from a import (b, c, d as dd)
    """), [parsepy.ImportStatement(name='a.b', new_name='b', is_from=True),
           parsepy.ImportStatement(name='a.c', new_name='c', is_from=True),
           parsepy.ImportStatement(name='a.d', new_name='dd', is_from=True)]) 
開發者ID:google,項目名稱:importlab,代碼行數:8,代碼來源:test_parsepy.py

示例15: test_asterisk

# 需要導入模塊: import a [as 別名]
# 或者: from a import b [as 別名]
def test_asterisk(self):
        self.assertEqual(self.parse("""
      from a import *
      from a.b import *
      from a . b . c import *
    """), [parsepy.ImportStatement(name='a', is_from=True, is_star=True),
           parsepy.ImportStatement(name='a.b', is_from=True, is_star=True),
           parsepy.ImportStatement(
               name='a.b.c', is_from=True, is_star=True)]) 
開發者ID:google,項目名稱:importlab,代碼行數:11,代碼來源:test_parsepy.py


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