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