[issue20383] Add a keyword-only spec argument to types.ModuleType
Brett Cannon
report at bugs.python.org
Mon May 5 15:54:14 CEST 2014
Brett Cannon added the comment:
My current thinking on this it to introduce in importlib.util:
def module_from_spec(spec, module=None):
"""Create/initialize a module based on the provided spec.
If a module is provided then spec.loader.create_module()
will not be consulted.
"""
This serves two purposes. One is that it abstracts the loader.create_module() dance out so that's no longer a worry. But more crucially it also means that if you have the function create the module for you then it will be returned with all of its attributes set without having to worry about forgetting that step. The module argument is just for convenience in those instances where you truly only want to override the module creation dance for some reason and really just want the attribute setting bit.
----------
nosy: +aronacher
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20383>
_______________________________________
More information about the Python-bugs-list
mailing list