4
from __future__ import unicode_literals
7
def ascii_format(a, int b, list c):
9
>>> print(ascii_format('x', 2, [1]))
12
return '-%a-%a-%a-' % (a, b, c)
15
def repr_format(a, int b, list c):
17
>>> print(repr_format('x', 2, [1]))
20
return '-%r-%r-%r-' % (a, b, c)
23
def str_format(a, int b, list c):
25
>>> print(str_format('x', 2, [1]))
28
return '-%s-%s-%s-' % (a, b, c)
31
def mix_format(a, int b, list c):
33
>>> print(mix_format('x', 2, [1]))
36
return '-%s-%r-%a-' % (a, b, c)
39
class PySubtype(unicode):
40
def __rmod__(self, other):
41
return f'PyRMOD({self}, {other})'
44
cdef class ExtSubtype(unicode):
45
def __rmod__(self, other):
46
return f'ExtRMOD({self}, {other})'
51
>>> py, ext = subtypes()
58
'-%s-' % PySubtype("PySub"),
59
'-%s-' % ExtSubtype("ExtSub"),
65
>>> print(format_int(5))
67
>>> print(format_int(5.0))
69
>>> format_int(u"xyz") # doctest: +ELLIPSIS
70
Traceback (most recent call last):
72
>>> format_int([]) # doctest: +ELLIPSIS
73
Traceback (most recent call last):
76
return "%d" % (value,)