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

Ron Adam ron3200 at gmail.com
Thu May 30 13:50:51 CEST 2013

On 05/30/2013 03: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.

>>> (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.

It manages the context, as in the above reference to context manager.

In this case the context is the loading and unloading of a module.  Having 
context managers names end with manager helps indicate how it's used.

But other verb+er combinations also work.  Taking a hint from the first few 
words of the __doc__ string gives us an obvious alternative.



More information about the Python-Dev mailing list