(機械翻訳) pyramid.compat

`` pyramid.compat``モジュールは、Pythonプラットフォームとバージョンの違いを超えて、Pyramidとそのアドオンのプラットフォームとバージョンの互換性を提供します。 Pyramidが互換性のあるインポートを必要とするシステムをサポートしなくなると、APIはこのモジュールから削除されます。

ascii_native_(s)[ソース]

Python 3: `` s``が `` text_type``のインスタンスであれば `` s.encode( 'ascii') ``を返し、そうでない場合は `` str(s、 'ascii'、 'strict') ` `

Python 2: `` s``が `` text_type``のインスタンスであれば、 `` s.encode( 'ascii') ``を返し、そうでなければ `` str(s) ``

binary_type

このプラットフォームのバイナリタイプ。 Python 3では `` bytes``です。 Python 2の場合、それは `` str``です。

bytes_(s, encoding='latin-1', errors='strict')[ソース]

`` s``が `` text_type``のインスタンスであれば `` s.encode(encoding、errors) ``を返し、そうでなければ `` s``を返します

class_types

このプラットフォームのクラス型のシーケンス。 Python 3では、 ``(type、) ``です。 Python 2では ``(type、types.ClassType) ``です。

configparser

Python 2では、 `` ConfigParser``モジュール、Python 3では `` configparser``モジュールです。

escape(v)[ソース]

Python 2では、 `` cgi.escape``関数、Python 3では `` html.escape``関数です。

exec_(code, globs=None, locs=None)

Python 2と3の両方で互換性のある方法でコードを実行します。

im_func

Python 2では、文字列値 `` im_func``、Python 3では文字列値 `` __func__``を使用します。

input_(v)

Python 2では、 `` raw_input``関数、Python 3では `` input``関数です。

integer_types

このプラットフォームの整数型のシーケンス。 Python 3では、 ``(int、) ``です。 Python 2では ``(int、long) ``です。

is_nonstr_iter(v)[ソース]

`` v``がPython 2とPython 3の両方で非 `` str``反復可能なら `` True``を返します。

iteritems_(d)[ソース]

Python 3では `` d.items() ``を、Python 2では `` d.iteritems() ``を返します。

itervalues_(d)[ソース]

Python 3では `` d.values() ``を、Python 2では `` d.itervalues() ``を返します。

iterkeys_(d)[ソース]

Python 3で `` d.keys() ``を、Python 2では `` d.iterkeys() ``を返します。

long

このプラットフォームのロングタイプ。 Python 3では `` int``です。 Python 2では `` long``です。

map_(v)[ソース]

Python 3では `` list(map(v)) ``を、Python 2では `` map(v) ``を返します。

pickle

`` cPickle``モジュールがあればそれを、 `` pickle``モジュールを返します。

PY3

Python 3では `` True``、そうでなければ `` False``です。

PYPY

PyPy上で実行している場合は `` True``、そうでなければ `` False``です。

reraise(tp, value, tb=None)[ソース]

`` reraise(* sys.exc_info()) ``のように、Python 2とPython 3の両方で互換性のある例外を発生させます。

string_types

このプラットフォームの文字列型のシーケンス。 Python 3では ``(str、) ``です。 Python 2では、 ``(ベースストリング) ``です。

SimpleCookie[ソース]

Python 2では、 `` Cookie.SimpleCookie``クラス、Python 3では、 `` http.cookies.SimpleCookie``モジュールです。

text_(s, encoding='latin-1', errors='strict')[ソース]

`` s``が `` binary_type``のインスタンスであれば `` s.decode(encoding、errors) ``を返し、そうでなければ `` s``を返します

text_type

このプラットフォームのテキストタイプ。 Python 3では `` str``です。 Python 2では、 `` unicode``です。

native_(s, encoding='latin-1', errors='strict')[ソース]

Python 3: `` s``が `` text_type``のインスタンスであれば `` s``を返し、そうでなければ `` str(s、encoding、errors)

Python 2: `` s``が `` text_type``のインスタンスであれば、 `` s.encode(encoding、errors) ``を返し、そうでなければ `` str(s) ``

urlparse

Python 2の `` urlparse``モジュール、Python 3の `` urllib.parse``モジュールです。

url_quote

Python 2の `` urllib.quote``関数、Python 3の `` urllib.parse.quote``関数です。

url_quote_plus

Python 2の `` urllib.quote_plus``関数、Python 3の `` urllib.parse.quote_plus``関数です。

url_unquote

Python 2の `` urllib.unquote``関数、Python 3の `` urllib.parse.unquote``関数です。

url_encode

Python 2の `` urllib.urlencode``関数、Python 3の `` urllib.parse.urlencode``関数です。

url_open

Python 2の `` urllib2.urlopen``関数、Python 3の `` urllib.request.urlopen``関数です。

url_unquote_text(v, encoding='utf-8', errors='replace')

Python 2では、 `` url_unquote(v).decode(encoding(encoding、errors)) ``を返します。 Python 3では、 `` urllib.parse.unquote``の結果を返します。

url_unquote_native(v, encoding='utf-8', errors='replace')

Python 2では `` native_(url_unquote_text_v、encoding、errors) ``を返します。 Python 3では、 `` urllib.parse.unquote``の結果を返します。