code: def from_file(f):
      
  
      if sys.hexversion >= 0x02030000:
          # allow Unicode filenames; turn on universal newline support
          str_type = basestring
          opts = 'rU'
      else:
          str_type = str
          opts = 'r'
      if isinstance(f, str_type):
          f = file(f, opts)
          want_close = True
      else:
          want_close = False
  
      try:
          m = from_text(f)
      finally:
          if want_close:
              f.close()
      return m
docs: Read the next text format message from the specified file.
  
      @param f: file or string.  If I{f} is a string, it is treated
      as the name of a file to open.
      @raises UnknownHeaderField:
      @raises dns.exception.SyntaxError:
      @rtype: dns.message.Message object