Package: drang-run
A simple command line tool to print sequences of numbers.drang-runis comparable tojotorseq, but with a more intuitive interface. It was inspired (and named after)a post by Dr. Drang.InstallationJust install like any other package:$pip3installdrang-runThis will install theruncommand.$run--versionrun, version 0.4.4UsageBasic usage includes up to three arguments:run [START] STOP [STEP][START]and[STEP]are optional and default to 1.$run41
2
3
4$run585
6
7
8$run01030
3
6
9Reverse the sequence with-r:$run4-r4
3
2
1Or switch the arguments:$run41-14
3
2
1Noterunwill try to guess the correct direction for the sequence based on the arguments. The example above could be simply written asrun 4 1.For conflicting sets of arguments, the values for START and STOP will take precedence over STEP. Sorun 1 4-1will be the same asrun 1 4 1.The only exeption to this isSTEP = 0which will cause an error.This also means thatrunwill almost never produce an empty output because at leastSTARTwill be part of the sequence.Format the output with--format. The option accepts any kind ofPython format string.$run9981002--format"{: >4}."998.
 999.
1000.
1001.
1002.You can use decimals for[START],STOPand[STEP]:$run1.11.5.151.1
1.25
1.4NoteIf at least one argument is a decimal, the output will be formatted as decimals as well.$run1.0411.0
2.0
3.0
4.0You can always change this by using appropriate format strings.$run1.041--format"{:g}"1
2
3
4Using letters for[START]andSTOPwill generate character sequences:$rundgd
e
f
gBy default, the items are separated by a newline character\n, but you can change this with-s:$rundg-s"\t"d       e       f       gRun additional sequences with--alsoSTART STOP STEP:$run12--also3411-3
1-4
2-3
2-4Note--alsorequires all three arguments to be present.Of course, this can be used with characters and be formatted:$run12--alsobc1--format"{0:02}. {1}_{1}"01. a_a
01. b_b
02. a_a
02. b_bNoteThe sequences can be referenced in the format string by order of appearance.-rwill reverseallsequences.Since version 0.4.0 you can define variables with the--defoption. A variable can be set to a simple arithmetic expression that is evaluated with the current counter values. Similar to the format string (-f) the counters can be referenced with{0},{1}and so on. All defined variables are initialized with0and can be used in other expressions, even in the definition of themselves.$run4--also131--defsum"{0}+{1}"--defakk"{akk}+{sum}"--format"{0} + {1} = {sum} ({akk})"1 + 1 = 2 (2)
1 + 2 = 3 (5)
1 + 3 = 4 (9)
2 + 1 = 3 (12)
2 + 2 = 4 (16)
2 + 3 = 5 (21)
3 + 1 = 4 (25)
3 + 2 = 5 (30)
3 + 3 = 6 (36)
4 + 1 = 5 (41)
4 + 2 = 6 (47)
4 + 3 = 7 (54)The expressions allow for some additional functions to be used. Notably therandint(max)andrand()functions for genrating random numbers:$run10--defr"randint(100)"--format"{r}"-s,51,0,55,50,56,43,20,5,51,90NoteThe expressions are evaluated using thesimpleevalmodule. Read the docs to see, what expressions are possible. In general, the basic arithmetic operators (+,-,*,/,*,//) are supported.In version 0.4.3 the--filteroption was added to filter out some values from the run. The option requires an expression similar to--defthat evaluates to a
boolean value. Any iteration that evaluates toFalsewill be omitted from the run.$run100--filter"{}%3==0 and {}%5==0"15
30
45
60
75
90ExamplesGenerating a CSV file with a lists of decimal, binary and hexadecimal numbers:$echo"dec,bin,oct,hex">hostnames.csv$run0255-f"{0:2},{0:08b},{0:02o},{0:02X}">>numbers.csvGenerating a list of computers in a network with hostnames and IP.$echo"room,hostname,ip">hostnames.csv$run4--also1241--also1161-f"{0}{1:02},r{0}{1:02}-{2:02},18.45.{1}{0}.{2}">>hostnames.csv