Skip to content

Commit 16d3870

Browse files
Sungmin-Joocorona10
authored andcommitted
Fix "end" option in print func (#90)
* Fix "end" option Fix line 190 to 193. The print function corrected the end option not applied. Added code performed when "end" value of parameter "kwargs" is not "nil". * Fix "end" option Fix line 190 to 193. The print function corrected the end option not applied. Added code performed when "end" value of parameter "kwargs" is not "nil". * add "end" option test add "end" option test in line 312 * add "end" option test add "end" option test add "end" option test in line 312
1 parent 70a66f2 commit 16d3870

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

builtin/builtin.go

+4
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ func builtin_print(self py.Object, args py.Tuple, kwargs py.StringDict) (py.Obje
187187
return nil, err
188188
}
189189
sep := sepObj.(py.String)
190+
191+
if kwargs["end"] != nil {
192+
endObj = kwargs["end"]
193+
}
190194
end := endObj.(py.String)
191195

192196
write, err := py.GetAttrString(file, "write")

builtin/tests/builtin.py

+6
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,12 @@ def gen2():
309309
with open("testfile", "r") as f:
310310
assert f.read() == "1,2,3,\n"
311311

312+
with open("testfile", "w") as f:
313+
print("hello",sep="",end="123", file=f)
314+
315+
with open("testfile", "r") as f:
316+
assert f.read() == "hello123"
317+
312318
doc="round"
313319
assert round(1.1) == 1.0
314320

0 commit comments

Comments
 (0)