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


Python six.PY3属性代码示例

本文整理汇总了Python中botocore.compat.six.PY3属性的典型用法代码示例。如果您正苦于以下问题:Python six.PY3属性的具体用法?Python six.PY3怎么用?Python six.PY3使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在botocore.compat.six的用法示例。


在下文中一共展示了six.PY3属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _get_text_writer

# 需要导入模块: from botocore.compat import six [as 别名]
# 或者: from botocore.compat.six import PY3 [as 别名]
def _get_text_writer(stream, errors):
        # In python3, all the sys.stdout/sys.stderr streams are in text
        # mode.  This means they expect unicode, and will encode the
        # unicode automatically before actually writing to stdout/stderr.
        # In python2, that's not the case.  In order to provide a consistent
        # interface, we can create a wrapper around sys.stdout that will take
        # unicode, and automatically encode it to the preferred encoding.
        # That way consumers can just call get_text_writer(stream) and write
        # unicode to the returned stream.  Note that get_text_writer
        # just returns the stream in the PY3 section above because python3
        # handles this.

        # We're going to use the preferred encoding, but in cases that there is
        # no preferred encoding we're going to fall back to assuming ASCII is
        # what we should use. This will currently break the use of
        # PYTHONIOENCODING, which would require checking stream.encoding first,
        # however, the existing behavior is to only use
        # locale.getpreferredencoding() and so in the hope of not breaking what
        # is currently working, we will continue to only use that.
        encoding = locale.getpreferredencoding()
        if encoding is None:
            encoding = "ascii"

        return codecs.getwriter(encoding)(stream, errors) 
开发者ID:gkrizek,项目名称:bash-lambda-layer,代码行数:26,代码来源:compat.py

示例2: is_resource_action

# 需要导入模块: from botocore.compat import six [as 别名]
# 或者: from botocore.compat.six import PY3 [as 别名]
def is_resource_action(action_handle):
    if six.PY3:
        return inspect.isfunction(action_handle)
    else:
        return inspect.ismethod(action_handle) 
开发者ID:skarlekar,项目名称:faces,代码行数:7,代码来源:utils.py

示例3: _is_binary

# 需要导入模块: from botocore.compat import six [as 别名]
# 或者: from botocore.compat.six import PY3 [as 别名]
def _is_binary(self, value):
        if isinstance(value, Binary):
            return True
        elif isinstance(value, bytearray):
            return True
        elif six.PY3 and isinstance(value, six.binary_type):
            return True
        return False 
开发者ID:skarlekar,项目名称:faces,代码行数:10,代码来源:types.py

示例4: compat_open

# 需要导入模块: from botocore.compat import six [as 别名]
# 或者: from botocore.compat.six import PY3 [as 别名]
def compat_open(filename, mode='r', encoding=None):
        # See docstring for compat_open in the PY3 section above.
        if 'b' not in mode:
            encoding = locale.getpreferredencoding()
        return io.open(filename, mode, encoding=encoding) 
开发者ID:gkrizek,项目名称:bash-lambda-layer,代码行数:7,代码来源:compat.py


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