Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(20936)

Side by Side Diff: Doc/library/importlib.rst

Issue 18864: Implementation for PEP 451 (importlib.machinery.ModuleSpec)
Patch Set: Created 5 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Doc/reference/import.rst » ('j') | Doc/reference/import.rst » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 :mod:`importlib` -- An implementation of :keyword:`import` 1 :mod:`importlib` -- An implementation of :keyword:`import`
2 ========================================================== 2 ==========================================================
3 3
4 .. module:: importlib 4 .. module:: importlib
5 :synopsis: An implementation of the import machinery. 5 :synopsis: An implementation of the import machinery.
6 6
7 .. moduleauthor:: Brett Cannon <brett@python.org> 7 .. moduleauthor:: Brett Cannon <brett@python.org>
8 .. sectionauthor:: Brett Cannon <brett@python.org> 8 .. sectionauthor:: Brett Cannon <brett@python.org>
9 9
10 .. versionadded:: 3.1 10 .. versionadded:: 3.1
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 .. method:: get_source(fullname) 874 .. method:: get_source(fullname)
875 875
876 Returns ``None`` as extension modules do not have source code. 876 Returns ``None`` as extension modules do not have source code.
877 877
878 .. method:: get_filename(fullname) 878 .. method:: get_filename(fullname)
879 879
880 Returns :attr:`path`. 880 Returns :attr:`path`.
881 881
882 .. versionadded:: 3.4 882 .. versionadded:: 3.4
883 883
884
885 .. class:: ModuleSpec(name, loader, *, origin=None, loader_state=None, is_packag e=None)
886
887 A specification for a module's import-system-related state.
888
889 .. versionadded:: 3.4
890
891 .. attribute:: name
892
893 (``__name__``)
894
895 A string for the fully-qualified name of the module.
896
897 .. attribute:: loader
898
899 (``__name__``)
brett.cannon 2013/11/08 21:26:09 Why the repeated specification of __name__? Just a
eric.snow 2013/11/09 05:26:29 The doc changes are still pretty raw, as you notic
900
901 The loader to use for loading. For namespace packages this will be
brett.cannon 2013/11/08 21:26:09 "this will" -> "this should" "set to None by find
eric.snow 2013/11/09 05:26:29 Done.
902 set to None.
903
904 .. attribute:: origin
905
906 (``__name__``)
907
908 Name of the place from which the module is loaded, e.g. "builtin" for
909 built-in modules and the filename for modules loaded from source.
910 "origin" may be None, but normally will be set.
brett.cannon 2013/11/08 21:26:09 "(or None if unspecified)".
eric.snow 2013/11/09 05:26:29 Done.
911
912 .. attribute:: submodule_search_locations
913
914 (``__name__``)
915
916 List of strings for where to find submodules, if a package (None
917 otherwise).
918
919 .. attribute:: loader_state
920
921 (``__name__``)
922
923 Container of extra module-specific data for use during loading (or
924 None).
925
926 .. attribute:: cached
927
928 (``__name__``)
929
930 String for where the compiled module should be stored (or None).
931
932 .. attribute:: parent
933
934 (``__name__``)
935
936 (Read-only) Fully-qualified name of the package to which the module
937 belongs as a submodule (or None).
938
939 .. attribute:: has_location
940
941 (``__name__``)
942
943 (Read-only) Boolean indicating whether or not the module's "origin"
944 attribute refers to a loadable location.
884 945
885 :mod:`importlib.util` -- Utility code for importers 946 :mod:`importlib.util` -- Utility code for importers
886 --------------------------------------------------- 947 ---------------------------------------------------
887 948
888 .. module:: importlib.util 949 .. module:: importlib.util
889 :synopsis: Utility code for importers 950 :synopsis: Utility code for importers
890 951
891 This module contains the various objects that help in the construction of 952 This module contains the various objects that help in the construction of
892 an :term:`importer`. 953 an :term:`importer`.
893 954
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 1084
1024 .. decorator:: set_package 1085 .. decorator:: set_package
1025 1086
1026 A :term:`decorator` for :meth:`importlib.abc.Loader.load_module` to set the : attr:`__package__` attribute on the returned module. If :attr:`__package__` 1087 A :term:`decorator` for :meth:`importlib.abc.Loader.load_module` to set the : attr:`__package__` attribute on the returned module. If :attr:`__package__`
1027 is set and has a value other than ``None`` it will not be changed. 1088 is set and has a value other than ``None`` it will not be changed.
1028 1089
1029 .. note:: 1090 .. note::
1030 As this decorator sets :attr:`__package__` after loading the module, it is 1091 As this decorator sets :attr:`__package__` after loading the module, it is
1031 recommended to use :meth:`importlib.abc.Loader.init_module_attrs` instead 1092 recommended to use :meth:`importlib.abc.Loader.init_module_attrs` instead
1032 when appropriate. 1093 when appropriate.
1094
1095 .. function:: spec_from_loader(name, loader, *, origin=None, is_package=None)
1096
1097 A factory function for creating a :class:`ModuleSpec` instance based
1098 on a loader. The parameters have the same meaning as they do for
1099 ModuleSpec. The function uses available :term:`loader` APIS, such as
brett.cannon 2013/11/08 21:26:09 APIs
eric.snow 2013/11/09 05:26:29 Done.
1100 :meth:`InspectLoader.is_package`, to fill in any missing
1101 information on the spec.
1102
1103 .. versionadded:: 3.4
1104
1105 .. function:: spec_from_file_location(name, location, *, loader=None, submodule_ search_locations=None)
1106
1107 A factory function for creating a :class:`ModuleSpec` instance based
1108 on the path to a file. Missing information will be filled in on the
1109 spec by making use of loader APIs and by the implication that the
1110 module will be file-based.
1111
1112 .. versionadded:: 3.4
OLDNEW
« no previous file with comments | « no previous file | Doc/reference/import.rst » ('j') | Doc/reference/import.rst » ('J')

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+