pyquery

changeset 84:885c218b5a4f tip

now .eq(index) quietly tolerates out-of-bounds indexes
author Emanuele Aina <emanuele.aina@dndg.it>
date Tue Mar 03 12:20:19 2009 +0100 (17 months ago)
parents fe14faeb9947
children
files pyquery/pyquery.py
line diff
     1.1 --- a/pyquery/pyquery.py	Mon Feb 16 17:58:04 2009 +0100
     1.2 +++ b/pyquery/pyquery.py	Tue Mar 03 12:20:19 2009 +0100
     1.3 @@ -252,8 +252,12 @@
     1.4              [<p.hello>]
     1.5              >>> d('p').eq(1)
     1.6              [<p>]
     1.7 +            >>> d('p').eq(2)
     1.8 +            []
     1.9          """
    1.10 -        return self.__class__([self[index]], **dict(parent=self))
    1.11 +        # Use slicing to silently handle out of bounds indexes
    1.12 +        items = self[index:index+1]
    1.13 +        return self.__class__(items, **dict(parent=self))
    1.14  
    1.15      def each(self, func):
    1.16          """apply func on each nodes

To download these repositories, get Mercurial and then type something like:

hg clone http://techn.ocracy.org/repository-name/

You can also click the "zip" or "gz" links to get an archive of the latest revision without installing anything.

The change logs of the repositories are aggregated at techn.ocracy.org/planet.

We have also some darcs repositories at techn.ocracy.org/darcs.