Function adas.random_tag

def random_tag(num=8)

Returns a random string of upper case letters and numbers.

Parameters

num : int
length of the requested string.

Returns

value : string
a random string to use as a tag.

Notes

This routine generates a booking reference style string of upper case letters and digits. It can be used to tag files or processes to keep them separate.

The routine only generates the string so the user must check whether it is unique or if there are any clashes.

Depends on the string and random libraries.

Reference

The idea is from stackoverflow https://stackoverflow.com/questions/2257441/random-string-generation-with-upper-case-letters-and-digits

Note the discussion that this is not suitable for cryptography applications.

Version History

  • Martin O'Mullane, 14-08-2022
    • First version

Example

A different, but similar in form, value should be generated.

>>> import adas as adas
>>> adas.random_tag(num=6)
'PJP30M'