Python National Insurance Number (NINo) one-line generator

Here’s a Python one-liner for generating a random UK National Insurance Number (aka NINo) on the command line, which is useful for testing apps that use one:

python -c 'import random; import string; p="ABCEGHJKLMNPRSTWXYZ"; print("".join([random.choice(p),random.choice(p)]+[random.choice(string.digits) for i in range(6)]+[random.choice("ABCD")]))'

To make it easier to use:

alias nino="python -c 'import random; import string; p=\"ABCEGHJKLMNPRSTWXYZ\"; print(\"\".join([random.choice(p),random.choice(p)]+[random.choice(string.digits) for i in range(6)]+[random.choice(\"ABCD\")]))'"

Tech mentioned