[Python-Dev] cpython: Introduce importlib.util.ModuleManager which is a context manager to

Alfredo Solano asolano at icai.es
Thu May 30 10:42:25 CEST 2013


Hi,

What about ModuleProxy?

 From the dictionary:

prox·y
/ˈpräksē/
Noun
The authority to represent someone else, esp. in voting.
A person authorized to act on behalf of another.
Synonyms
deputy - representative - agent - substitute

Alfredo

On 05/30/2013 10:34 AM, Mark Shannon wrote:
>
>
> On 29/05/13 01:14, Brett Cannon wrote:
>> On Tue, May 28, 2013 at 5:40 PM, Antoine Pitrou <solipsis at pitrou.net> 
>> wrote:
>>> On Tue, 28 May 2013 23:29:46 +0200 (CEST)
>>> brett.cannon <python-checkins at python.org> wrote:
>>>>
>>>> +.. class:: ModuleManager(name)
>>>> +
>>>> + A :term:`context manager` which provides the module to load. The 
>>>> module will
>>>> + either come from :attr:`sys.modules` in the case of reloading or 
>>>> a fresh
>>>> + module if loading a new module. Proper cleanup of 
>>>> :attr:`sys.modules` occurs
>>>> + if the module was new and an exception was raised.
>>>
>>> What use case does this API solve?
>>
>> See http://bugs.python.org/issue18088 for the other part of this
>> story. I'm basically replacing what importlib.util.module_for_loader
>> does after I realized there is no way in a subclass to override
>> what/how attributes are set on a module before the code object is
>> executed. Instead of using the decorator people will be able to use
>> this context manager with a new method to get the same effect with the
>> ability to better control attribute initialization.
>>
>>> (FWIW, I think "ModuleManager" is a rather bad name :-)
>
> +1. XxxManager is what Java programmers call their classes when they 
> are forced to have an
> unnecessary class because they don't have 1st class functions or modules.
>
> (I don't like 'Context Manager' either, but it's too late to change it 
> :( )
>
>>
>> I'm open to suggestions, but the thing does manage the module so it at
>> least makes sense.
>
> But what do you mean by managing? 'Manage' has many meanings.
> Once you've answered that question you should have your name.
>
> Cheers,
> Mark.
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: 
> http://mail.python.org/mailman/options/python-dev/asolano%40icai.es



More information about the Python-Dev mailing list