def uuid4():
 if _uuid_generate_random:
  _buffer = ctypes.create_string_buffer(16)
  _uuid_generate_random(_buffer)
  return UUID(bytes=_buffer.raw)
 try:
  import os
  return UUID(bytes=os.urandom(16), version=4)
 except:
  import random
  bytes = [chr(random.randrange(256)) for i in range(16)]
  return UUID(bytes=bytes, version=4)

def uuid4 ( ) : if _uuid_generate_random : _buffer = ctypes . create_string_buffer ( 16 ) _uuid_generate_random ( _buffer ) return UUID ( bytes = _buffer . raw ) try : import os return UUID ( bytes = os . urandom ( 16 ) , version = 4 ) except : import random bytes = [ chr ( random . randrange ( 256 ) ) for i in range ( 16 ) ] return UUID ( bytes = bytes , version = 4 )
generate a random uuid .