Skip to main content

Generate a run of integers or characters. Similar to jot and seq.

Project description

A simple command line tool to print sequences of numbers.

drang-run is comparable to jot or seq, but with a more intuitive interface. It was inspired (and named after) a post by Dr. Drang.

Installation

Just install like any other package:

$ pip3 install drang-run

This will install the run command.

$ run --version
run, version 0.3.6

Usage

Basic usage includes up to three arguments:

run [START] STOP [STEP]

[START] and [STEP] are optional and default to 1.

$ run 4
1
2
3
4
$ run 5 8
5
6
7
8
$ run 0 10 3
0
3
6
9

Reverse the sequence with -r:

$ run 4 -r
4
3
2
1

Or switch the arguments:

$ run 4 1 -1
4
3
2
1

Format the output with --format. The option accepts any kind of Python format string.

$ run 998 1002 --format "{: >4}."
998.
999.
1000.
1001.
1002.

You can use decimals for [START], STOP and [STEP]:

$ run 1.1 1.5 .15
1.1
1.25
1.4

Using letters for [START] and STOP will generate character sequences:

$ run d g
d
e
f
g

By default, the items are separated by a newline character \n, but you can change this with -s:

$ run d g -s "\t"
d       e       f       g

Run additional sequences with --also START STOP STEP:

$ run 1 2 --also 3 4 1
1-3
1-4
2-3
2-4

Of course, this can be used with characters and be formatted:

$ run 1 2 --also b c 1 --format "{0:02}. {1}_{1}"
01. a_a
01. b_b
02. a_a
02. b_b

Since version 0.4.0 you can define variables with the --def option. A variable can be set to a simple arithmetic expression that is evaluated with the current counter values.

$ run 4 --also 1 3 1 --def sum "{0}+{1}" --def akk "{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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

drang-run-0.4.0.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

drang_run-0.4.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file drang-run-0.4.0.tar.gz.

File metadata

  • Download URL: drang-run-0.4.0.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.9.7 Darwin/21.1.0

File hashes

Hashes for drang-run-0.4.0.tar.gz
Algorithm Hash digest
SHA256 65475b1f1367f57182b79cc364dbfface55d64e93c3ca211663350ead2e0e9d9
MD5 704c879a41becacb5748cb4194f59ee6
BLAKE2b-256 8dddb164f0f8bbafc2a2da2cf0bd6f0438cf2475fe3fb4fdcc48786d8ea03b0d

See more details on using hashes here.

File details

Details for the file drang_run-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: drang_run-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.9.7 Darwin/21.1.0

File hashes

Hashes for drang_run-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 688c1b335391e0bedb54f0657c79b98642522c872d4ba7e5f37c6a543bb320b4
MD5 8d451bbac4e0f50914b0d4bee4d83e9b
BLAKE2b-256 c1243ec2b75b555dd4f93338416ea0255feda8cffb4a4826baf3071faa464c6f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page