Commits

Gael Pasgrimaud committed f044bd0

reimplement + and extend

Comments (0)

Files changed (2)

pyquery/README.txt

     ...style="font-size: 17px"...
     </html>
 
+You can generate html stuff::
+
+    >>> from pyquery import PyQuery as pq
+    >>> print pq('<div>Yeah !</div>').addClass('myclass') + pq('<b>cool</b>')
+    <div class="myclass">Yeah !</div><b>cool</b>
+
 For more documentation about the API use the jquery website http://jquery.com/
 
 You can run the doctests that you just read by running the test function or by

pyquery/pyquery.py

             args += (self,)
         return self.__class__(*args)
 
+    # keep original list api prefixed with _
+    _append = list.append
+    _extend = list.extend
+
+    # improve pythonic api
+    def __add__(self, other):
+        assert isinstance(other, self.__class__)
+        return self.__class__(self[:] + other[:])
+
+    def extend(self, other):
+        assert isinstance(other, self.__class__)
+        self._extend(other[:])
+
     def __str__(self):
         return ''.join([etree.tostring(e) for e in self])