Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(4)  |  Call(3)  |  Derive(0)  |  Import(1)

        def which(p,l):
    try:
        return filter(partial(lambda g,t: g(t[1]), p), 
                enumerate(l))[0][0]
    except IndexError:
        return -1
        


src/l/i/list115utils-1.0.1/list115utils/test/test_listutils.py   list115utils(Download)
        self.assertListEqual(flatten_deep([]), [])
 
from list115utils import which, p_true
class TestWhich(TestListUtils):
    def setUp(self):
        self.items = ['a', 'abc', 'abcd', 'abcde', 'ad', 'def', 'defg', '', 'hijklmn']
    def test_which_selects_the_right_positions(self):
        self.assertEqual(which(p_medium, self.items), 2)
    def test_which_returns_negative_one_if_not_found(self):
        self.assertEqual(which(p_long, self.items), -1)
 
    def test_which_returns_0_for_tautology(self):
        self.assertEqual(which(p_true, self.items), 0)