code: def bytes_cast(maybe_str, encoding='utf-8'):
      
      if isinstance(maybe_str, unicode_):
          return maybe_str.encode(encoding)
      else:
          return maybe_str
docs: Converts any string-like input to a bytes-like output, with respect to
      python version
  
      Parameters
      ----------
      maybe_str : if this is a string-like object, it will be converted to bytes
      encoding  : str, default='utf-8'
          encoding to be used when encoding string