parameters: ()
docstring: Generate a random UUID.
docstring_summary: Generate a random UUID.
docstring_tokens: Generate a random UUID .
function: def uuid4():
      """Generate a random UUID."""
  
      # When the system provides a version-4 UUID generator, use it.
      if _uuid_generate_random:
          _uuid_generate_random(_buffer)
          return UUID(bytes=_buffer.raw)
  
      # Otherwise, get randomness from urandom or the 'random' module.
      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)
function_tokens: def uuid4 ( ) : # When the system provides a version-4 UUID generator, use it. if _uuid_generate_random : _uuid_generate_random ( _buffer ) return UUID ( bytes = _buffer . raw ) # Otherwise, get randomness from urandom or the 'random' module. 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 )