parameters: (seq)
docstring: convert a sequence to a bytes type
docstring_summary: convert a sequence to a bytes type
docstring_tokens: convert a sequence to a bytes type
function: def to_bytes(seq):
      """convert a sequence to a bytes type"""
      if isinstance(seq, bytes):
          return seq
      elif isinstance(seq, bytearray):
          return bytes(seq)
      elif isinstance(seq, memoryview):
          return seq.tobytes()
      elif isinstance(seq, unicode):
          raise TypeError('unicode strings are not supported, please encode to bytes: {!r}'.format(seq))
      else:
          # handle list of integers and bytes (one or more items) for Python 2 and 3
          return bytes(bytearray(seq))
function_tokens: def to_bytes ( seq ) : if isinstance ( seq , bytes ) : return seq elif isinstance ( seq , bytearray ) : return bytes ( seq ) elif isinstance ( seq , memoryview ) : return seq . tobytes ( ) elif isinstance ( seq , unicode ) : raise TypeError ( 'unicode strings are not supported, please encode to bytes: {!r}' . format ( seq ) ) else : # handle list of integers and bytes (one or more items) for Python 2 and 3 return bytes ( bytearray ( seq ) )