This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add examples for importlib in doc
Type: Stage: resolved
Components: Documentation Versions: Python 3.4, Python 3.5
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Saimadhav.Heblikar, brett.cannon, docs@python, eric.snow, martin.panter, ncoghlan, raulcd
Priority: normal Keywords: patch

Created on 2014-03-31 04:42 by Saimadhav.Heblikar, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
importlib-example.patch Saimadhav.Heblikar, 2014-03-31 04:42 review
Messages (3)
msg215220 - (view) Author: Saimadhav Heblikar (Saimadhav.Heblikar) * Date: 2014-03-31 04:42
The imp module was the defacto module to access the import internals,upto 3.3
It has been deprecated(pending) in 3.4 in favor of importlib.
There are plenty of examples on how to use imp around the web, but very little (even in doc.python.org), on how to use importlib. 

The proposed patch adds couple of examples. These examples are aimed towards people, who were earlier using imp's load_module().

Inspiration for the patch from this SO answer, where user had to go through source code.
http://stackoverflow.com/questions/19009932/import-abitrary-python-source-file-python-3-3
msg215246 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2014-03-31 15:54
While I'm totally happy to add examples on usage, it is probably best to put them at the end of the class-level docs instead of trailing after the last method of the class. That way someone reading about what the class does can also see examples of how to use it.

Another point is that SourceFileLoader.load_module() is documented as deprecated as of Python 3.4 and so promoting it in an example is not good. Now that module creation has been broken out separately this "create a module from a file path" approach is becoming more and more difficult. If we care to continue to support this use case we will probably need to come up with a function(s) to make it easier and toss something up on PyPI that is Python 2.7-3.5 compatible.
msg364551 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2020-03-18 18:30
There are now examples in the importlib docs.
History
Date User Action Args
2022-04-11 14:58:01adminsetgithub: 65307
2020-03-18 18:30:02brett.cannonsetstatus: open -> closed
resolution: out of date
messages: + msg364551

stage: resolved
2015-04-13 14:33:55raulcdsetnosy: + raulcd
2014-04-17 07:05:32martin.pantersetnosy: + martin.panter
2014-03-31 15:54:09brett.cannonsetmessages: + msg215246
versions: + Python 3.5
2014-03-31 06:50:24ned.deilysetnosy: + brett.cannon, ncoghlan, eric.snow
2014-03-31 04:43:31Saimadhav.Heblikarsettitle: Add doc examples for importlib -> Add examples for importlib in doc
2014-03-31 04:42:24Saimadhav.Heblikarcreate