Python 2 and 3 Compatibility¶
-
sage.misc.six.
int2byte
(*args, **kwds)¶ S.pack(v1, v2, …) -> bytes
Return a bytes object containing values v1, v2, … packed according to the format string S.format. See help(struct) for more on format strings.
-
sage.misc.six.
u
(x)¶ Convert \(x\) to unicode, assuming UTF-8 encoding.
Python2 behaviour:
If input is unicode, returns the input.
If input is str (assumed to be utf-8 encoded), convert to unicode.
Python3 behaviour:
If input is str, returns the input.
If input is bytes (assumed to be utf-8 encoded), convert to unicode.
EXAMPLES:
sage: from sage.misc.six import u sage: u("500 €") u'500 \u20ac' sage: u(u"500 \u20ac") u'500 \u20ac'