Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
23763168
Kaydet (Commit)
23763168
authored
Eyl 08, 2016
tarafından
Brett Cannon
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #27853: Add section headers to the importlib example docs
üst
7322225a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
importlib.rst
Doc/library/importlib.rst
+19
-0
No files found.
Doc/library/importlib.rst
Dosyayı görüntüle @
23763168
...
...
@@ -1353,6 +1353,9 @@ an :term:`importer`.
Examples
--------
Importing programmatically
''''''''''''''''''''''''''
To programmatically import a module, use :func:`importlib.import_module`.
::
...
...
@@ -1360,6 +1363,10 @@ To programmatically import a module, use :func:`importlib.import_module`.
itertools = importlib.import_module('
itertools
')
Checking if a module can be imported
''''''''''''''''''''''''''''''''''''
If you need to find out if a module can be imported without actually doing the
import, then you should use :func:`importlib.util.find_spec`.
::
...
...
@@ -1380,6 +1387,10 @@ import, then you should use :func:`importlib.util.find_spec`.
# Adding the module to sys.modules is optional.
sys.modules[name] = module
Importing a source file directly
''''''''''''''''''''''''''''''''
To import a Python source file directly, use the following recipe
(Python 3.4 and newer only)::
...
...
@@ -1398,6 +1409,10 @@ To import a Python source file directly, use the following recipe
# by name later.
sys.modules[module_name] = module
Setting up an importer
''''''''''''''''''''''
For deep customizations of import, you typically want to implement an
:term:`importer`. This means managing both the :term:`finder` and :term:`loader`
side of things. For finders there are two flavours to choose from depending on
...
...
@@ -1428,6 +1443,10 @@ classes defined within this package)::
# of priority.
sys.path_hooks.append(SpamPathEntryFinder.path_hook(loader_details))
Approximating :func:`importlib.import_module`
'''''''''''''''''''''''''''''''''''''''''''''
Import itself is implemented in Python code, making it possible to
expose most of the import machinery through importlib. The following
helps illustrate the various APIs that importlib exposes by providing an
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment