tests/seq.py
branchstable
changeset 49366 288de6f5d724
parent 49285 56f98406831b
equal deleted inserted replaced
49364:e8ea403b1c46 49366:288de6f5d724
     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
       
    11 import os
    10 import os
    12 import sys
    11 import sys
    13 
    12 
    14 try:
    13 try:
    15     import msvcrt
    14     import msvcrt
    18     msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
    17     msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
    19     msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
    18     msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
    20 except ImportError:
    19 except ImportError:
    21     pass
    20     pass
    22 
    21 
    23 if sys.version_info[0] >= 3:
       
    24     xrange = range
       
    25 
       
    26 start = 1
    22 start = 1
    27 if len(sys.argv) > 2:
    23 if len(sys.argv) > 2:
    28     start = int(sys.argv[1])
    24     start = int(sys.argv[1])
    29 
    25 
    30 step = 1
    26 step = 1
    31 if len(sys.argv) > 3:
    27 if len(sys.argv) > 3:
    32     step = int(sys.argv[2])
    28     step = int(sys.argv[2])
    33 
    29 
    34 stop = int(sys.argv[-1]) + 1
    30 stop = int(sys.argv[-1]) + 1
    35 
    31 
    36 for i in xrange(start, stop, step):
    32 for i in range(start, stop, step):
    37     print(i)
    33     print(i)