Skip to content

Commit 5e16b88

Browse files
committed
Add 'sep' and 'end' arguments to print().
1 parent 98e8aa7 commit 5e16b88

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

functional_tests/print.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
print('foo')
22
print('foo', 'bar')
3+
print('foo', 'bar', sep='bla')
4+
print('foo', 'bar', sep='bla', end='bli')
5+
print('foo', 'bar', end='bli')

pythonlib/builtins.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
BaseException = __primitives__.BaseException
22
RuntimeError = __primitives__.RuntimeError
33

4-
def print(*values):
4+
def print(*values, sep=' ', end='\n'):
55
first = True
66
for value in values:
77
if first:
88
first = False
99
else:
10-
__primitives__.write_stdout(" ")
10+
__primitives__.write_stdout(sep)
1111
__primitives__.write_stdout(value)
1212

13-
__primitives__.write_stdout("\n")
13+
__primitives__.write_stdout(end)
1414

1515
__build__class__ = __primitives__.build_class
1616
issubclass = __primitives__.issubclass

0 commit comments

Comments
 (0)