Attribute and method calling#

class, args, kwds)#

Bases: object, *args, **kwds)#

Return a callable which takes in an object, gets the method named name from that object, and calls it with the specified arguments and keywords.


  • name - a string of the name of the method you want to call

  • args, kwds - arguments and keywords to be passed to the method


sage: f = attrcall('core', 3); f
sage: [f(p) for p in Partitions(5)]                                             # needs sage.combinat
[[2], [1, 1], [1, 1], [3, 1, 1], [2], [2], [1, 1]], name, *args, **kwds)#

Call the method name on obj.

This has to exist somewhere in Python!!!

See also

operator.methodcaller() attrcal()


sage: from import call_method
sage: call_method(1, "__add__", 2)