Use print() function in both Python 2 and Python 3

This commit is contained in:
cclauss 2018-10-08 22:31:00 +02:00 committed by GitHub
parent a9b8c9bb39
commit df43e4fdbd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,4 +1,6 @@
#!/usr/bin/env python2
from __future__ import print_function
import sys
ESCAPE = chr(27)
@ -14,19 +16,19 @@ def reset():
if __name__ == "__main__":
if len(sys.argv) < 6:
print 'Usage: colortest.py fg_start fg_end bg_start bg_end test_string'
print('Usage: colortest.py fg_start fg_end bg_start bg_end test_string')
sys.exit(1)
fg_start, fg_end, bg_start, bg_end = map(int, sys.argv[1:5])
test_string = sys.argv[5]
print ' ' * len(str(bg_start)),
print(' ' * len(str(bg_start)), end=' ')
for fg_color in range(fg_start, fg_end + 1):
print ' ' * (len(test_string) - len(str(fg_color))), fg_color,
print(' ' * (len(test_string) - len(str(fg_color))), fg_color, end=' ')
print
for bg_color in range(bg_start, bg_end + 1):
print bg_color, bg(bg_color),
print(bg_color, bg(bg_color), end=' ')
for fg_color in range(fg_start, fg_end + 1):
print fg(fg_color), test_string,
print reset()
print(fg(fg_color), test_string, end=' ')
print(reset())