##// END OF EJS Templates
tests: force `seq` to print with '\n' EOL...
Matt Harbison -
r52878:2924676d default
parent child Browse files
Show More
@@ -1,33 +1,31
1 #!/usr/bin/env python3
1 #!/usr/bin/env python3
2 #
2 #
3 # A portable replacement for 'seq'
3 # A portable replacement for 'seq'
4 #
4 #
5 # Usage:
5 # Usage:
6 # seq STOP [1, STOP] stepping by 1
6 # seq STOP [1, STOP] stepping by 1
7 # seq START STOP [START, STOP] stepping by 1
7 # seq START STOP [START, STOP] stepping by 1
8 # seq START STEP STOP [START, STOP] stepping by STEP
8 # seq START STEP STOP [START, STOP] stepping by STEP
9
9
10 import os
10 import io
11 import sys
11 import sys
12
12
13 try:
13 sys.stdout = io.TextIOWrapper(
14 import msvcrt
14 sys.stdout.buffer,
15
15 sys.stdout.encoding,
16 msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
16 sys.stdout.errors,
17 msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
17 newline="\n",
18 msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
18 )
19 except ImportError:
20 pass
21
19
22 start = 1
20 start = 1
23 if len(sys.argv) > 2:
21 if len(sys.argv) > 2:
24 start = int(sys.argv[1])
22 start = int(sys.argv[1])
25
23
26 step = 1
24 step = 1
27 if len(sys.argv) > 3:
25 if len(sys.argv) > 3:
28 step = int(sys.argv[2])
26 step = int(sys.argv[2])
29
27
30 stop = int(sys.argv[-1]) + 1
28 stop = int(sys.argv[-1]) + 1
31
29
32 for i in range(start, stop, step):
30 for i in range(start, stop, step):
33 print(i)
31 print(i)
General Comments 0
You need to be logged in to leave comments. Login now