Commits

holger krekel committed 4d677af

introduce py.builtin.any

Comments (0)

Files changed (4)

 - major refactoring of internal collection handling
 - majorly reduce py.test core code, shift function/python testing to own plugin
 - fix issue88 (finding custom test nodes from command line arg)
+- introduce py.builtin.any()
 
 Changes between 1.3.3 and 1.3.4
 ==================================================
         'enumerate'      : '._builtin:enumerate',
         'reversed'       : '._builtin:reversed',
         'sorted'         : '._builtin:sorted',
+        'any'            : '._builtin:any',
         'set'            : '._builtin:set',
         'frozenset'      : '._builtin:frozenset',
         'BaseException'  : '._builtin:BaseException',
             return self.remaining
 
 try:
+    any = any
+except NameError:
+    def any(iterable):
+        for x in iterable:
+            if x:
+                return True
+        return False
+
+try:
     sorted = sorted
 except NameError:
     builtin_cmp = cmp # need to use cmp as keyword arg

testing/root/test_builtin.py

     for i,x in enumerate(l):
         assert i == x
 
+def test_any():
+    assert not py.builtin.any([0,False, None])
+    assert py.builtin.any([0,False, None,1])
+
 def test_BaseException():
     assert issubclass(IndexError, py.builtin.BaseException)
     assert issubclass(Exception, py.builtin.BaseException)