module with __call__ defined is not callable?

adam johnson adam.sven.johnson at gmail.com
Tue Feb 7 21:38:13 EST 2006


Hi All.
I was wondering why defining a __call__ attribute for a module doesn't make
it actually callable.

I don't have any reason for doing so, I was just wondering if it worked, and
found out it didn't.

$ cat mod.py
"""
Test callable module
"""
def __call__():
    return "in mod.__call__"


>>> import mod
>>> mod()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: 'module' object is not callable
>>> mod.__call__()
'in mod.__call__'


Thanks for any replies, Adam.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060208/c421b5df/attachment.html>


More information about the Python-list mailing list