def filter(self, selector):
        """Filter elements in self using selector (string or function).

            >>> d = PyQuery('<p class="hello">Hi</p><p>Bye</p>')
            >>> d('p')
            [<p.hello>, <p>]
            >>> d('p').filter('.hello')
            [<p.hello>]
            >>> d('p').filter(lambda i: i == 1)
            [<p>]
            >>> d('p').filter(lambda i: PyQuery(this).text() == 'Hi')
            [<p.hello>]
        """
        if not hasattr(selector, '__call__'):
            return self._filter_only(selector, self)
        else:
            elements = []
            try:
                for i, this in enumerate(self):
                    func_globals(selector)['this'] = this
                    if callback(selector, i):
                        elements.append(this)
            finally:
                f_globals = func_globals(selector)
                if f_globals in 'this':
                    del f_globals['this']
            return self.__class__(elements, **dict(parent=self))
dataset/ETHPy150Open dsc/pyquery/pyquery/pyquery.py/PyQuery.filter/swapped operands of `in`