import os import binascii import uuid from xid import Xid def get_guid(style='uuid'): """Get a globally unique string for identify things""" if style == 'uuid': return uuid.uuid4().hex if style == 'xid': return Xid().string() raise RuntimeError('Unsupported guid style: {0}'.format(style)) # Equivalent implementation def get_guid(): return binascii.hexlify(os.urandom(16)).decode()