mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
![]() Consider the following directory structure: . └── PATH1 └── namespace └── sub1 └── __init__.py And both PATH1 and PATH2 in sys path: $ PYTHONPATH=PATH1:PATH2 python3.11 >>> import namespace >>> import namespace.sub1 >>> namespace.__path__ _NamespacePath(['.../PATH1/namespace']) >>> ... While this interpreter still runs, PATH2/namespace/sub2 is created: . ├── PATH1 │ └── namespace │ └── sub1 │ └── __init__.py └── PATH2 └── namespace └── sub2 └── __init__.py The newly created module cannot be imported: >>> ... >>> namespace.__path__ _NamespacePath(['.../PATH1/namespace']) >>> import namespace.sub2 Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'namespace.sub2' Calling importlib.invalidate_caches() now newly allows to import it: >>> import importlib >>> importlib.invalidate_caches() >>> namespace.__path__ _NamespacePath(['.../PATH1/namespace']) >>> import namespace.sub2 >>> namespace.__path__ _NamespacePath(['.../PATH1/namespace', '.../PATH2/namespace']) This was not previously possible. |
||
---|---|---|
.. | ||
builtin | ||
data | ||
data01 | ||
data02 | ||
data03 | ||
extension | ||
frozen | ||
import_ | ||
namespace_pkgs | ||
namespacedata01 | ||
partial | ||
resources | ||
source | ||
zipdata01 | ||
zipdata02 | ||
__init__.py | ||
__main__.py | ||
abc.py | ||
fixtures.py | ||
stubs.py | ||
test_abc.py | ||
test_api.py | ||
test_compatibilty_files.py | ||
test_contents.py | ||
test_files.py | ||
test_lazy.py | ||
test_locks.py | ||
test_main.py | ||
test_metadata_api.py | ||
test_namespace_pkgs.py | ||
test_open.py | ||
test_path.py | ||
test_pkg_import.py | ||
test_read.py | ||
test_reader.py | ||
test_resource.py | ||
test_spec.py | ||
test_threaded_import.py | ||
test_util.py | ||
test_windows.py | ||
test_zip.py | ||
threaded_import_hangers.py | ||
update-zips.py | ||
util.py |