New submission from Stephen Fairchild <signupaddr...@bethere.co.uk>:
From: http://docs.python.org/reference/datamodel.html#the-standard-type-hierarchy "Class instances Class instances are described below. Class instances are callable only when the class has a __call__() method; x(arguments) is a shorthand for x.__call__(arguments)." The following program demonstrates otherwise regarding that last statement. def call(self): print "inserted __call__ in object of class A" class A(object): def __call__(self): print "__call__ method in class A" x = A() # Equates: x = type(A).__call__(A) x.__call__ = call x() # Calls the method of class A. x.__call__(x) # Calls function "call". type(x).__call__(x) # The correct longhand of x() IMHO If I were to rephrase the documentation: "Class instances Class instances are described below. Class instances are callable only when the class has a __call__() method; x(arguments) is a shorthand for type(x).__call__(x, arguments)." ---------- assignee: georg.brandl components: Documentation messages: 91864 nosy: georg.brandl, onlyme severity: normal status: open title: Class calling type: behavior versions: Python 2.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue6761> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com