def filterWith(self, filters, other=False):
        """
        Apply a set of pre-defined filters on a known set of events and return
        the filtered list of event numbers.

        The pre-defined events are four events with a C{count} attribute set to
        C{0}, C{1}, C{2}, and C{3}.

        @param filters: names of the filters to apply.

            Options are:

                - C{"twoMinus"} (count <=2),

                - C{"twoPlus"} (count >= 2),

                - C{"notTwo"} (count != 2),

                - C{"no"} (False).

        @type filters: iterable of str

        @param other: Whether to return a list of filtered events as well.
        @type other: L{bool}

        @return: event numbers or 2-tuple of lists of event numbers.
        @rtype: L{list} of L{int} or 2-L{tuple} of L{list} of L{int}
        """
        events = [
            dict(count=0),
            dict(count=1),
            dict(count=2),
            dict(count=3),
        ]

        class Filters(object):
            @staticmethod
            def twoMinus(event):
                """
                count <= 2

                @param event: an event
                @type event: dict

                @return: L{PredicateResult.yes} if C{event["count"] <= 2},
                    otherwise L{PredicateResult.maybe}.
                """
                if event["count"] <= 2:
                    return PredicateResult.yes
                return PredicateResult.maybe

            @staticmethod
            def twoPlus(event):
                """
                count >= 2

                @param event: an event
                @type event: dict

                @return: L{PredicateResult.yes} if C{event["count"] >= 2},
                    otherwise L{PredicateResult.maybe}.
                """
                if event["count"] >= 2:
                    return PredicateResult.yes
                return PredicateResult.maybe

            @staticmethod
            def notTwo(event):
                """
                count != 2

                @param event: an event
                @type event: dict

                @return: L{PredicateResult.yes} if C{event["count"] != 2},
                    otherwise L{PredicateResult.maybe}.
                """
                if event["count"] == 2:
                    return PredicateResult.no
                return PredicateResult.maybe

            @staticmethod
            def no(event):
                """
                No way, man.

                @param event: an event
                @type event: dict

                @return: L{PredicateResult.no}
                """
                return PredicateResult.no

            @staticmethod
            def bogus(event):
                """
                Bogus result.

                @param event: an event
                @type event: dict

                @return: something other than a valid predicate result.
                """
                return None

        predicates = (getattr(Filters, f) for f in filters)
        eventsSeen = []
        eventsNotSeen = []
        trackingObserver = eventsSeen.append
        if other:
            extra = [eventsNotSeen.append]
        else:
            extra = []
        filteringObserver = FilteringLogObserver(
            trackingObserver, predicates, *extra
        )
        for e in events:
            filteringObserver(e)

        if extra:
            return (
                [e["count"] for e in eventsSeen],
                [e["count"] for e in eventsNotSeen],
            )
        return [e["count"] for e in eventsSeen]

        Apply a set of pre-defined filters on a known set of events and return
        the filtered list of event numbers.

        The pre-defined events are four events with a C{count} attribute set to
        C{0}, C{1}, C{2}, and C{3}.

        @param filters: names of the filters to apply.

            Options are:

                - C{"twoMinus"} (count <=2),

                - C{"twoPlus"} (count >= 2),

                - C{"notTwo"} (count != 2),

                - C{"no"} (False).

        @type filters: iterable of str

        @param other: Whether to return a list of filtered events as well.
        @type other: L{bool}

        @return: event numbers or 2-tuple of lists of event numbers.
        @rtype: L{list} of L{int} or 2-L{tuple} of L{list} of L{int}
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/logger/test/test_filter.py