@@ -574,6 +574,8 @@ Pure paths provide the following methods and properties:
574
574
>>> PureWindowsPath('b.py').match('*.PY')
575
575
True
576
576
577
+ For an overview of available patterns see :meth: `Path.glob `, with the
578
+ exception that "``** ``" behaves just like "``* ``".
577
579
578
580
.. method :: PurePath.relative_to(other, walk_up=False)
579
581
@@ -861,9 +863,7 @@ call fails (for example because the path doesn't exist).
861
863
>>> sorted(Path('.').glob('*/*.py'))
862
864
[PosixPath('docs/conf.py')]
863
865
864
- Patterns are the same as for :mod: `fnmatch `, with the addition of "``** ``"
865
- which means "this directory and all subdirectories, recursively". In other
866
- words, it enables recursive globbing::
866
+ "``** ``" enables recursive globbing::
867
867
868
868
>>> sorted(Path('.').glob('**/*.py'))
869
869
[PosixPath('build/lib/pathlib.py'),
@@ -872,6 +872,22 @@ call fails (for example because the path doesn't exist).
872
872
PosixPath('setup.py'),
873
873
PosixPath('test_pathlib.py')]
874
874
875
+ The following wildcards are available:
876
+
877
+ +------------+------------------------------------+
878
+ | Pattern | Meaning |
879
+ +============+====================================+
880
+ | ``** `` | matches everything, recursively |
881
+ +------------+------------------------------------+
882
+ | ``* `` | matches everything |
883
+ +------------+------------------------------------+
884
+ | ``? `` | matches any single character |
885
+ +------------+------------------------------------+
886
+ | ``[seq] `` | matches any character in *seq * |
887
+ +------------+------------------------------------+
888
+ | ``[!seq] `` | matches any character not in *seq * |
889
+ +------------+------------------------------------+
890
+
875
891
.. note ::
876
892
Using the "``** ``" pattern in large directory trees may consume
877
893
an inordinate amount of time.
@@ -1270,8 +1286,7 @@ call fails (for example because the path doesn't exist).
1270
1286
.. method :: Path.rglob(pattern)
1271
1287
1272
1288
Glob the given relative *pattern * recursively. This is like calling
1273
- :func: `Path.glob ` with "``**/ ``" added in front of the *pattern *, where
1274
- *patterns * are the same as for :mod: `fnmatch `::
1289
+ :func: `Path.glob ` with "``**/ ``" added in front of the *pattern *::
1275
1290
1276
1291
>>> sorted(Path().rglob("*.py"))
1277
1292
[PosixPath('build/lib/pathlib.py'),
@@ -1280,6 +1295,8 @@ call fails (for example because the path doesn't exist).
1280
1295
PosixPath('setup.py'),
1281
1296
PosixPath('test_pathlib.py')]
1282
1297
1298
+ For an overview of available patterns see :meth: `Path.glob `.
1299
+
1283
1300
.. audit-event :: pathlib.Path.rglob self,pattern pathlib.Path.rglob
1284
1301
1285
1302
.. versionchanged :: 3.11
0 commit comments