本文整理汇总了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)
示例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)
示例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
示例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)