uid()

audeer.uid(*, from_string=None, short=False)[source]

Generate unique identifier.

A unique identifier contains 36 characters with - at position 9, 14, 19, 24. If short is True, only the last 8 digits are returned.

Parameters
  • from_string (Optional[str]) – create a unique identifier by hashing the provided string. This will return the same identifier for identical strings. If None uuid.uuid1() is used.

  • short (bool) – if True returns a short unique identifier (last 8 digits)

Return type

str

Returns

unique identifier

Examples

>>> uid(from_string="example_string")
'626f68e6-d336-70b9-e753-ed9fad855840'
>>> uid(from_string="example_string", short=True)
'ad855840'