[Python-ideas] making a module callable

Philipp A. flying-sheep at web.de
Tue Nov 19 22:01:14 CET 2013


2013/11/19 Michael Foord <fuzzyman at gmail.com>

On 19 November 2013 18:09, Philipp A. <flying-sheep at web.de> wrote:
>>
>> imho it would simplify the situation. currently, everything is callable
>> that has a __call__ property which is itself callable:
>>
> This is why module objects are not callable even if they have a __call__.
> They are *instances* of ModuleType and the __call__ method is looked up on
> their type, not the instance itself. So modules not being callable even
> when they a __call__ is not an anomaly, even if it is not convenient
> sometimes.
>
you’re right, apologies. so the hack consists of switching a module’s class
during runtime…

there’s also another hack, calldules<https://pypi.python.org/pypi/calldules>,
making that automatic (funnily via implicits effects when doing import
calldules). note that it isn’t serious! just a programming exercise.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20131119/81aef7a1/attachment.html>


More information about the Python-ideas mailing list