File tree 1 file changed +30
-0
lines changed
1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 9
9
package py
10
10
11
11
import (
12
+ "fmt"
12
13
"unicode/utf8"
13
14
)
14
15
@@ -137,8 +138,37 @@ func (a String) M__ge__(other Object) Object {
137
138
return NotImplemented
138
139
}
139
140
141
+ // % operator
142
+
143
+ func (a String ) M__mod__ (other Object ) Object {
144
+ var values Tuple
145
+ switch b := other .(type ) {
146
+ case Tuple :
147
+ values = b
148
+ default :
149
+ values = Tuple {other }
150
+ }
151
+ // FIXME not a full implementation ;-)
152
+ return String (fmt .Sprintf ("%s %#v" , a , values ))
153
+ }
154
+
155
+ func (a String ) M__rmod__ (other Object ) Object {
156
+ switch b := other .(type ) {
157
+ case String :
158
+ return b .M__mod__ (a )
159
+ }
160
+ return NotImplemented
161
+ }
162
+
163
+ func (a String ) M__imod__ (other Object ) Object {
164
+ return a .M__mod__ (other )
165
+ }
166
+
140
167
// Check stringerface is satisfied
141
168
var _ richComparison = String ("" )
142
169
var _ sequenceArithmetic = String ("" )
170
+ var _ I__mod__ = String ("" )
171
+ var _ I__rmod__ = String ("" )
172
+ var _ I__imod__ = String ("" )
143
173
var _ I__len__ = String ("" )
144
174
var _ I__bool__ = String ("" )
You can’t perform that action at this time.
0 commit comments