[issue21108] Add doc examples for importlib
New submission from Saimadhav Heblikar: 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-fi... ---------- assignee: docs@python components: Documentation files: importlib-example.patch keywords: patch messages: 215220 nosy: docs@python, sahutd priority: normal severity: normal status: open title: Add doc examples for importlib versions: Python 3.4 Added file: http://bugs.python.org/file34675/importlib-example.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue21108> _______________________________________
Changes by Saimadhav Heblikar <saimadhavheblikar@gmail.com>: ---------- title: Add doc examples for importlib -> Add examples for importlib in doc _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue21108> _______________________________________
Changes by Ned Deily <nad@acm.org>: ---------- nosy: +brett.cannon, eric.snow, ncoghlan _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue21108> _______________________________________
Brett Cannon added the comment: 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. ---------- versions: +Python 3.5 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue21108> _______________________________________
Changes by Martin Panter <vadmium+py@gmail.com>: ---------- nosy: +vadmium _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue21108> _______________________________________
Changes by Raúl Cumplido <raulcumplido@gmail.com>: ---------- nosy: +raulcd _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue21108> _______________________________________
Brett Cannon <brett@python.org> added the comment: There are now examples in the importlib docs. ---------- resolution: -> out of date stage: -> resolved status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue21108> _______________________________________
participants (5)
-
Brett Cannon
-
Martin Panter
-
Ned Deily
-
Raúl Cumplido
-
Saimadhav Heblikar