1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# mode: run
# tag: stringformat
from __future__ import unicode_literals
def ascii_format(a, int b, list c):
"""
>>> print(ascii_format('x', 2, [1]))
-'x'-2-[1]-
"""
return '-%a-%a-%a-' % (a, b, c)
def repr_format(a, int b, list c):
"""
>>> print(repr_format('x', 2, [1]))
-'x'-2-[1]-
"""
return '-%r-%r-%r-' % (a, b, c)
def str_format(a, int b, list c):
"""
>>> print(str_format('x', 2, [1]))
-x-2-[1]-
"""
return '-%s-%s-%s-' % (a, b, c)
def mix_format(a, int b, list c):
"""
>>> print(mix_format('x', 2, [1]))
-x-2-[1]-
"""
return '-%s-%r-%a-' % (a, b, c)
class PySubtype(unicode):
def __rmod__(self, other):
return f'PyRMOD({other})'
cdef class ExtSubtype(unicode):
def __mod__(one, other):
return f'ExtMOD({one}, {other})'
def subtypes():
"""
>>> py, ext = subtypes()
>>> print(py)
PyRMOD(-%s-)
>>> print(ext)
ExtMOD(-%s-, ExtSub)
"""
return [
'-%s-' % PySubtype("PySub"),
'-%s-' % ExtSubtype("ExtSub"),
]
|