Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit efc92ee

Browse files
committed
PEP 214, Extended print Statement, has been accepted by the BDFL.
Additional test cases for the extended print form.
1 parent 8c0a242 commit efc92ee

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

Lib/test/output/test_grammar

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ print_stmt
1919
1 2 3
2020
1 2 3
2121
1 1 1
22+
extended print_stmt
23+
1 2 3
24+
1 2 3
25+
1 1 1
2226
del_stmt
2327
pass_stmt
2428
flow_stmt

Lib/test/test_grammar.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,25 @@ def d22v(a, b, c=1, d=2, *rest): pass
260260
print 0 or 1, 0 or 1,
261261
print 0 or 1
262262

263+
print 'extended print_stmt' # 'print' '>>' test ','
264+
import sys
265+
print >> sys.stdout, 1, 2, 3
266+
print >> sys.stdout, 1, 2, 3,
267+
print >> sys.stdout
268+
print >> sys.stdout, 0 or 1, 0 or 1,
269+
print >> sys.stdout, 0 or 1
270+
271+
# syntax errors
272+
def check_syntax(statement):
273+
try:
274+
compile(statement, '<string>', 'exec')
275+
except SyntaxError:
276+
pass
277+
else:
278+
print 'Missing SyntaxError: "%s"' % statement
279+
check_syntax('print ,')
280+
check_syntax('print >> x,')
281+
263282
print 'del_stmt' # 'del' exprlist
264283
del abc
265284
del x, y, (z, xyz)

0 commit comments

Comments
 (0)