Mercurial > hg-stable
view tests/seq.py @ 50219:829aa604d71a
typing: add the return type hint to pycompat.rangelist()
Not bothering with the args, because there are a few overloads and only 2
callers in the codebase, one of which is a test.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Tue, 21 Feb 2023 13:26:07 -0500 |
parents | 56f98406831b |
children | 2924676d4728 |
line wrap: on
line source
#!/usr/bin/env python3 # # A portable replacement for 'seq' # # Usage: # seq STOP [1, STOP] stepping by 1 # seq START STOP [START, STOP] stepping by 1 # seq START STEP STOP [START, STOP] stepping by STEP import os import sys try: import msvcrt msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY) except ImportError: pass start = 1 if len(sys.argv) > 2: start = int(sys.argv[1]) step = 1 if len(sys.argv) > 3: step = int(sys.argv[2]) stop = int(sys.argv[-1]) + 1 for i in range(start, stop, step): print(i)