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