This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author onlyme
Recipients georg.brandl, onlyme
Date 2009-08-22.17:13:56
SpamBayes Score 0.0033232945
Marked as misclassified No
Message-id <1250961239.16.0.126736964049.issue6761@psf.upfronthosting.co.za>
In-reply-to
Content
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)."
History
Date User Action Args
2009-08-22 17:13:59onlymesetrecipients: + onlyme, georg.brandl
2009-08-22 17:13:59onlymesetmessageid: <1250961239.16.0.126736964049.issue6761@psf.upfronthosting.co.za>
2009-08-22 17:13:57onlymelinkissue6761 messages
2009-08-22 17:13:56onlymecreate