Skip to content

Commit f123039

Browse files
committed
Add section on Namespace Packages. Fixes python#262.
1 parent 388d87b commit f123039

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

docs/using.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,27 @@ example could also be written as::
122122
eml = files(email.tests.data).joinpath('message.eml').read_text()
123123

124124

125+
Namespace Packages
126+
==================
127+
128+
``importlib_resources`` supports namespace packages as anchors just like
129+
any other package. Similar to modules in a namespace package,
130+
resources in a namespace package are not allowed to collide by name.
131+
For example, if two packages both expose ``nspkg/data/foo.txt``, those
132+
resources are unsupported by this library. The package will also likely
133+
experience problems due to the collision with installers.
134+
135+
It's perfectly valid, however, for two packages to present different resources
136+
in the same namespace package, regular package, or subdirectory.
137+
For example, one package could expose ``nspkg/data/foo.txt`` and another
138+
expose ``nspkg/data/bar.txt`` and those two packages could be installed
139+
into separate paths, and the resources should be queryable::
140+
141+
data = importlib_resources.files('nspkg').joinpath('data')
142+
data.joinpath('foo.txt').read_text()
143+
data.joinpath('bar.txt').read_text()
144+
145+
125146
File system or zip file
126147
=======================
127148

0 commit comments

Comments
 (0)