[Python-ideas] making a module callable

Chris Angelico rosuav at gmail.com
Wed Nov 20 17:15:54 CET 2013


On Thu, Nov 21, 2013 at 3:12 AM,  <random832 at fastmail.us> wrote:
> On Tue, Nov 19, 2013, at 18:20, Chris Angelico wrote:
>> But is there any way to avoid the chicken-and-egg problem of trying to
>> logically put that into the same source file as the module whose
>> metaclass is being changed? Considering that the creation of a class
>> involves building up its dictionary of contents and _then_ calling
>> type(), it could in theory be possible to build up a dictionary of
>> module contents, possibly find something with a magic name like
>> __metamodule__, and then use that as the module's type. But this might
>> become rather convoluted.
>
> Isn't this how metaclasses used to actually work?

Is it? I've no idea. I haven't been doing complex stuff in Python all
that long, so I don't know any of the details back past about 2.5 or
so (apart from what I've learned since).

ChrisA


More information about the Python-ideas mailing list