[Python-Dev] cpython: Introduce importlib.util.ModuleManager which is a context manager to
Brett Cannon
brett at python.org
Wed May 29 16:47:16 CEST 2013
More information about the Python-Dev mailing list
Wed May 29 16:47:16 CEST 2013
- Previous message: [Python-Dev] cpython: Introduce importlib.util.ModuleManager which is a context manager to
- Next message: [Python-Dev] cpython: Introduce importlib.util.ModuleManager which is a context manager to
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, May 29, 2013 at 10:34 AM, Nick Coghlan <ncoghlan at gmail.com> wrote: > 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. You should use this context manager to get the correct module to initialize/execute/whatever, e.g. contextlib.closing is about what the context manager is going to do for you, not what you are doing to the object it returned. > > 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) I am willing to compromise to module_to_initialize, module_to_init, or module_to_load. Pick one. =)
- Previous message: [Python-Dev] cpython: Introduce importlib.util.ModuleManager which is a context manager to
- Next message: [Python-Dev] cpython: Introduce importlib.util.ModuleManager which is a context manager to
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list