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

Method xpath_even_pseudo

pyquery/cssselectpatch.py:78–90  ·  view source on GitHub ↗

Matches even elements, zero-indexed:: >>> from pyquery import PyQuery >>> d = PyQuery(' ') >>> d('p:even') [ ] ..

(self, xpath)

Source from the content-addressed store, hash-verified

76 return xpath
77
78 def xpath_even_pseudo(self, xpath):
79 """Matches even elements, zero-indexed::
80
81 >>> from pyquery import PyQuery
82 >>> d = PyQuery('<div><p></p><p class="last"></p></div>')
83 >>> d('p:even')
84 [<p>]
85
86 ..
87 """
88 # the first element is 1 in xpath and 0 in python and js
89 xpath.add_post_condition('position() mod 2 = 1')
90 return xpath
91
92 def xpath_odd_pseudo(self, xpath):
93 """Matches odd elements, zero-indexed::

Callers

nothing calls this directly

Calls 1

add_post_conditionMethod · 0.80

Tested by

no test coverage detected