Show More
@@ -1,27 +1,36 | |||
|
1 | 1 | #!/usr/bin/env python |
|
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 | 10 | from __future__ import absolute_import, print_function |
|
11 | import os | |
|
11 | 12 | import sys |
|
12 | 13 | |
|
14 | try: | |
|
15 | import msvcrt | |
|
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 | |
|
21 | ||
|
13 | 22 | if sys.version_info[0] >= 3: |
|
14 | 23 | xrange = range |
|
15 | 24 | |
|
16 | 25 | start = 1 |
|
17 | 26 | if len(sys.argv) > 2: |
|
18 | 27 | start = int(sys.argv[1]) |
|
19 | 28 | |
|
20 | 29 | step = 1 |
|
21 | 30 | if len(sys.argv) > 3: |
|
22 | 31 | step = int(sys.argv[2]) |
|
23 | 32 | |
|
24 | 33 | stop = int(sys.argv[-1]) + 1 |
|
25 | 34 | |
|
26 | 35 | for i in xrange(start, stop, step): |
|
27 | 36 | print(i) |
General Comments 0
You need to be logged in to leave comments.
Login now