当前位置: 首页>>代码示例>>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;未经允许,请勿转载。