def uuid4():
    """Generate a random UUID."""
    # Otherwise, get randomness from urandom or the 'random' module.
    try:
        import os
        return UUID(bytes=os.urandom(16), version=4)
    except Exception:
        import random
        bytes = [chr(random.randrange(256)) for i in range(16)]
        return UUID(bytes=bytes, version=4)
def uuid4 ( ) : try : import os return UUID ( bytes = os . urandom ( 16 ) , version = 4 ) except Exception : import random bytes = [ chr ( random . randrange ( 256 ) ) for i in range ( 16 ) ] return UUID ( bytes = bytes , version = 4 )
Generate a random UUID.