Steven D'Aprano <[EMAIL PROTECTED]> wrote:

> As far as I know, all it would take to allow modules to be callable
> would be a single change to the module type, the equivalent of:
> 
> def __call__(self, *args, **kwargs):
>     try:
>         # Special methods are retrieved from the class, not
>         # from the instance, so we need to see if the 
>         # instance has the right method.
>         callable = self.__dict__['__call__']
>     except KeyError:
>         return None # or raise an exception?
>     return callable(self, *args, **kwargs)
> 

The error should throw "TypeError: 'module' object is not callable" just as 
it does today.

Also, it shouldn't pass self through to callable: modules have functions 
not methods.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to