code: def limit(self, limit):
          
          if not isinstance(limit, integer_types):
              raise TypeError("limit must be an integer")
          if self.__exhaust:
              raise InvalidOperation("Can't use limit and exhaust together.")
          self.__check_okay_to_chain()
  
          self.__empty = False
          self.__limit = limit
          return self
docs: Limits the number of results to be returned by this cursor.
  
          Raises :exc:`TypeError` if `limit` is not an integer. Raises
          :exc:`~pymongo.errors.InvalidOperation` if this :class:`Cursor`
          has already been used. The last `limit` applied to this cursor
          takes precedence. A limit of ``0`` is equivalent to no limit.
  
          :Parameters:
            - `limit`: the number of results to return
  
          .. mongodoc:: limit