On Wed, May 29, 2013 at 10:34 AM, Nick Coghlan <ncogh...@gmail.com> wrote: > On Wed, May 29, 2013 at 11:04 PM, Brett Cannon <br...@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. =) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com