[Python-ideas] TypeError: 'module' object is not callable

Guido van Rossum guido at python.org
Fri Feb 20 18:47:28 CET 2009


Oh, we could easily add a __call__ to the module type that looks for a
__call__ function. I just don't think it's a good idea.

On Fri, Feb 20, 2009 at 9:35 AM, Christian Heimes <lists at cheimes.de> wrote:
> Ralf W. Grosse-Kunstleve wrote:
>> I see there have been discussion about module __call__ about three years ago:
>>
>> http://mail.python.org/pipermail/python-list/2006-February/thread.html#366176
>>
>> Is there an existing pronouncement on this subject?
>>
>> __call__ would help avoiding strange things like from StringIO import StringIO
>> or having to come up with silly names like run, driver, manager, etc.
>>
>> Ideally, __call__ could be either a function or class.
>>
>> I imagine, nothing special, except that a module object looks for __call__ instead
>> of producing a type error.
>
>
> It's technically not possible without jumping through several loops.
> Magic methods are looked up on the class. Modules are instances of the
> ModuleType class.
>
> Christian
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>



-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-ideas mailing list