code: def from_file(cls, filename_or_file_object):
          
          object_ = from_file(filename_or_file_object)
          if not isinstance(object_, cls):
              raise ValueError('Expected to read {0!r} object, but got {1!r} instead'.format(cls, type(object_)))
  
          return object_
docs: Create new instance of the object from the file.
          :param filename_or_file_object: the filename of the file to read from or already opened file buffer
          :type filename_or_file_object: basestring|file