[Python-ideas] making a module callable

Andrew Barnert abarnert at yahoo.com
Thu Nov 21 02:57:11 CET 2013


On Nov 20, 2013, at 12:14, Eric Snow <ericsnowcurrently at gmail.com> wrote:

> In contrast, something like __metamodule__ would be an effective
> replacement.  It would be similar in spirit and in syntax to
> __init_class__ in PEP 422 (and __metaclass__ in Python 2), defined at
> the top of the module and used for the module.  The thing that appeals
> to me is that we could deprecate the sys.modules hack. :)

Given that __metaclass__ was removed in Python 3, doesn't "this is an exact parallel to __metaclass__" argue against the idea, rather than for? Or at least against the name? (Maybe __init_module__?)

Anyway, I think a module replacing itself with something callable is both more flexible and more in line with the way people are actually doing things today, so maybe a "less hacky" way to do the sys.modules hack is what people actually want here.


More information about the Python-ideas mailing list