Thanks for you answer.<br><br>I was under the impression that you could tack methods onto an object at any time, your example almost works with old style classes and would with a function instead of a method.<br><br>>>> class A:
<br>...     def __init__(self):<br>...             self.__call__ = A.hello<br>...     def hello(self):<br>...             print "Hello, world!"<br>...<br>>>> a = A()<br>>>> a()<br>Traceback (most recent call last):
<br>  File "<stdin>", line 1, in ?<br>TypeError: unbound method hello() must be called with A instance as first argument (got nothing instead)<br>>>> a(a)<br>Hello, world!<br>>>><br><br>So now all I need to know is why now with new style classes the special
functions need to be defined on the class instead of attached to the
instance at any time.<br>
<br><br><div><span class="gmail_quote">On 08/02/06, <b class="gmail_sendername">Delaney, Timothy (Tim)</b> <<a href="mailto:tdelaney@avaya.com">tdelaney@avaya.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
adam johnson wrote:<br><br>> Hi All.<br>> I was wondering why defining a __call__ attribute for a module<br>> doesn't make it actually callable.<br><br>For the same reason that the following doesn't work<br><br>    class A (object):
<br><br>        def __init__(self):<br>            self.__call__ = A.hello<br><br>        def hello (self):<br>            print 'Hello, world!'<br><br>    a = A()<br>    a()<br><br>    Traceback (most recent call last):<br>
      File "D:\Python\modules\testclasscall.py", line 10, in ?<br>        a()<br>    TypeError: 'A' object is not callable<br><br>The __call__ attribute must be defined on the class (or type) - not on<br>the instance. A module is an instance of <type 'module'>.
<br><br>Tim Delaney<br>--<br><a href="http://mail.python.org/mailman/listinfo/python-list">http://mail.python.org/mailman/listinfo/python-list</a><br></blockquote></div><br>