Debian Codegraph @

tests/seq.py

raw
1 #!/usr/bin/env python3
2 #
3 # A portable replacement for 'seq'
4 #
5 # Usage:
6 # seq STOP [1, STOP] stepping by 1
7 # seq START STOP [START, STOP] stepping by 1
8 # seq START STEP STOP [START, STOP] stepping by STEP
9
10 import io
11 import sys
12
13 sys.stdout = io.TextIOWrapper(
14 sys.stdout.buffer,
15 sys.stdout.encoding,
16 sys.stdout.errors,
17 newline="\n",
18 )
19
20 start = 1
21 if len(sys.argv) > 2:
22 start = int(sys.argv[1])
23
24 step = 1
25 if len(sys.argv) > 3:
26 step = int(sys.argv[2])
27
28 stop = int(sys.argv[-1]) + 1
29
30 for i in range(start, stop, step):
31 print(i)