[Python-Dev] cpython: Introduce importlib.util.ModuleManager which is a context manager to
ncoghlan at gmail.com
Wed May 29 16:34:40 CEST 2013
On Wed, May 29, 2013 at 11:04 PM, Brett Cannon <brett at python.org> wrote:
>> with initialise_module(name) as m:
>> # Module initialisation code goes here
>> # Module is rolled back if initialisation fails
> But you're not initializing the module; more like getting the module, either
> new or from sys.modules. But I thought ModuleGetter seemed too Java-like.
> Could hide the class behind a get_module function though.
The point is to provide a useful mnemonic for *why* you would use this
context manager, and the reason is because the body of the with
statement is going to initialize the contents, and you want to unwind
things appropriately if that fails.
initializing_module is probably a better name than initialized_module,
though (since it isn't initialized yet on entry - instead, that's what
should be the case by the end of the statement)
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-Dev