MCPcopy Create free account
hub / github.com/gawel/pyquery / parents

Method parents

pyquery/pyquery.py:526–540  ·  view source on GitHub ↗

>>> d = PyQuery(' Hi Bye ') >>> d('p').parents() [ ] >>> d('.hello').parents('span') [ ] >>> d('.hello').parents('p') []

(self, selector=None)

Source from the content-addressed store, hash-verified

524 return self._filter_only(selector, self._prev_all() + self._next_all())
525
526 def parents(self, selector=None):
527 """
528 >>> d = PyQuery('<span><p class="hello">Hi</p><p>Bye</p></span>')
529 >>> d('p').parents()
530 [<span>]
531 >>> d('.hello').parents('span')
532 [<span>]
533 >>> d('.hello').parents('p')
534 []
535 """
536 return self._filter_only(
537 selector,
538 [e for e in self._traverse_parent_topdown()],
539 unique=True
540 )
541
542 def children(self, selector=None):
543 """Filter elements that are direct children of self using optional

Callers

nothing calls this directly

Calls 2

_filter_onlyMethod · 0.95

Tested by

no test coverage detected