[issue14551] imp.load_source docs removed from python3 docs...is this correct?

R. David Murray report at bugs.python.org
Mon Apr 16 20:10:49 CEST 2012

R. David Murray <rdmurray at bitdance.com> added the comment:

Well, if you want backward compatibility, you pretty much have to keep it as is, don't you?

This is the only time I've used load_source, and it was used because we didn't want to bother mucking with the path but did want to load the module whose file system location we knew.

SourceFileLoader(name, path).load_source() is OK, but it does not qualify as an obvious API for loading a module not on the path whose file system path one knows.  I'm OK with there not being an obvious API for that as long as there *is* an API for it.

To be clear: importlib.import_module(name) lets you load a module that *is* on the path, so it seems logical that there would be a corresponding function (load_file?) that would take a complete path and thereby allow you to load a module *not* on sys.path.  But there is by no means a *requirement* for such a function in my mind, as long as it can be done somehow.


Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list