[Python-ideas] making a module callable
Ethan Furman
ethan at stoneleaf.us
Thu Nov 21 03:40:07 CET 2013
On 11/20/2013 05:57 PM, Andrew Barnert wrote:
> On Nov 20, 2013, at 12:14, Eric Snow 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.
sys.modules is a dictionary.
dict[name] = something
is the normal way to set values to keys.
What is so horrible about this idiom?
--
~Ethan~
More information about the Python-ideas
mailing list