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

Method xpath_first_pseudo

pyquery/cssselectpatch.py:52–63  ·  view source on GitHub ↗

Matches the first selected element:: >>> from pyquery import PyQuery >>> d = PyQuery(' ') >>> d('p:first') [ ] ..

(self, xpath)

Source from the content-addressed store, hash-verified

50 xpathexpr_cls = XPathExpr
51
52 def xpath_first_pseudo(self, xpath):
53 """Matches the first selected element::
54
55 >>> from pyquery import PyQuery
56 >>> d = PyQuery('<div><p class="first"></p><p></p></div>')
57 >>> d('p:first')
58 [<p.first>]
59
60 ..
61 """
62 xpath.add_post_condition('position() = 1')
63 return xpath
64
65 def xpath_last_pseudo(self, xpath):
66 """Matches the last selected element::

Callers

nothing calls this directly

Calls 1

add_post_conditionMethod · 0.80

Tested by

no test coverage detected