code: def deep_encode(s, encoding='utf-8', errors='strict'):
      
      # encoding defaults to the default encoding. errors may be given to set
      # a different error handling scheme. Default is 'strict' meaning
      # that encoding errors raise
      # a UnicodeEncodeError. Other possible values are 'ignore', 'replace' and
      # 'xmlcharrefreplace' as well as any other name registered with
      # codecs.register_error that can handle UnicodeEncodeErrors.
      s = deep_encode(s)
      if sys.version_info.major < 3 and isinstance(s, unicode):
          return s.encode(encoding, errors)
      if isinstance(s, (list, tuple)):
          return [deep_encode(i, encoding=encoding, errors=errors) for i in s]
      if isinstance(s, dict):
          return dict([
              (
                  deep_encode(key, encoding=encoding, errors=errors),
                  deep_encode(s[key], encoding=encoding, errors=errors)
              ) for key in s
          ])
          # new_dict = {}
          # for key in s:
          #     new_dict[
          #         to_encode(key, encoding=encoding, errors=errors)
          #     ] = to_encode(s[key], encoding=encoding, errors=errors)
          # return new_dict
      return s
docs: Encode "DEEP" S using the codec registered for encoding.