當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。