uuid#

uuid(uid=None, which=None, die=False, tostring=False, length=None, n=1, **kwargs)[source]#

Shortcut for creating a UUID; default is to create a UUID4. Can also convert a UUID.

Parameters:
  • uid (str or uuid) – if a string, convert to an actual UUID; otherwise, return unchanged

  • which (int or str) – if int, choose a Python UUID function; otherwise, generate a random alphanumeric string (default 4)

  • die (bool) – whether to fail for converting a supplied uuid (default False)

  • tostring (bool) – whether or not to return a string instead of a UUID object (default False)

  • length (int) – number of characters to trim to, if returning a string

  • n (int) – number of UUIDs to generate; if n>1, return a list

Returns:

the UID object

Return type:

uid (UUID or str)

Examples:

sc.uuid() # Alias to uuid.uuid4()
sc.uuid(which='hex') # Creates a length-6 hex string
sc.uuid(which='ascii', length=10, n=50) # Creates 50 UUIDs of length 10 each using the full ASCII character set