Did I find the right examples for you? yes no

All Samples(6)  |  Call(6)  |  Derive(0)  |  Import(0)
Given a callable object `callable`, and a mapping of arguments
`args`, call `callable` with arguments taken from `args`. The
arguments are found by matching argument names from the values
in `args`.

        def apply(callable, args):
    '''Given a callable object `callable`, and a mapping of arguments
       `args`, call `callable` with arguments taken from `args`. The
       arguments are found by matching argument names from the values
       in `args`.'''

    return callable(*getargs(callable, args))
        


src/c/a/calllib-1.3/test/test_calllib.py   calllib(Download)
    def test_no_init(self):
        # test old style
        class C():
            pass
        o = calllib.apply(C, {})
    def test_no_init_new_style(self):
        # and new style
        class C(object):
            pass
        o = calllib.apply(C, {})
                self.x = x+1
 
        o = calllib.apply(Derived, {'x': 42})
        self.assertIsInstance(o, Derived)
        self.assertEqual(o.x, 42)
 
        o = calllib.apply(Derived1, {'x': 41})
                self.x = x+1
 
        o = calllib.apply(Derived, {'x': 42})
        self.assertIsInstance(o, Derived)
        self.assertEqual(o.x, 42)