Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e6d579d

Browse files
committed
Added docs for glob
1 parent 20af95b commit e6d579d

7 files changed

Lines changed: 77 additions & 5 deletions

File tree

Doc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ LIBFILES = lib.tex \
113113
libxdrlib.tex libimghdr.tex \
114114
librestricted.tex librexec.tex libbastion.tex \
115115
libformatter.tex liboperator.tex libsoundex.tex libresource.tex \
116-
libstat.tex libstrio.tex libundoc.tex libmailcap.tex
116+
libstat.tex libstrio.tex libundoc.tex libmailcap.tex libglob.tex
117117

118118
# Library document
119119
lib.dvi: $(LIBFILES)

Doc/lib/liballos.tex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,7 @@ \chapter{Generic Operating System Services}
2323
\item[errno]
2424
--- Standard errno system symbols.
2525

26+
\item[glob]
27+
--- Unix shell style pathname pattern expansion.
28+
2629
\end{description}

Doc/lib/libglob.tex

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
\section{Standard Module \sectcode{glob}}
2+
\stmodindex{glob}
3+
\renewcommand{\indexsubitem}{(in module glob)}
4+
5+
The \code{glob} module finds all the pathnames matching a specified
6+
pattern according to the rules used by the \UNIX{} shell. No tilde
7+
expansion is done, but \verb\*\, \verb\?\, and character ranges
8+
expressed with \verb\[]\ will be correctly matched. This is done by
9+
using the \code{os.listdir()} and \code{fnmatch.fnmatch()} functions
10+
in concert, and not by actually invoking a subshell. (For tilde and
11+
shell variable expansion, use \code{os.path.expanduser(}) and
12+
\code{os.path.expandvars()}.)
13+
14+
\begin{funcdesc}{glob}{pathname}
15+
Returns a possibly-empty list of path names that match \var{pathname},
16+
which must be a string containing a path specification.
17+
\var{pathname} can be either absolute (like
18+
\file{/usr/src/Python1.4/Makefile}) or relative (like
19+
\file{../../Tools/*.gif}), and can contain shell-style wildcards.
20+
\end{funcdesc}
21+
22+
For example, consider a directory containing only the following files:
23+
\file{1.gif}, \file{2.txt}, and \file{card.gif}. \code{glob.glob()}
24+
will produce the following results. Notice how any leading components
25+
of the path are preserved.
26+
27+
\begin{verbatim}
28+
>>> import glob
29+
>>> glob.glob('./[0-9].*')
30+
['./1.gif', './2.txt']
31+
>>> glob.glob('*.gif')
32+
['1.gif', 'card.gif']
33+
>>> glob.glob('?.gif')
34+
['1.gif']
35+
\end{verbatim}

Doc/lib/libundoc.tex

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ \section{Miscellaneous useful utilities}
5353

5454
Some of these are very old and/or not very robust; marked with ``hmm''.
5555

56-
glob.py -- filename globbing (high level interface)
57-
5856
fnmatch.py -- filename globbing (low level interface)
5957

6058
calendar.py -- Calendar printing functions

Doc/liballos.tex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,7 @@ \chapter{Generic Operating System Services}
2323
\item[errno]
2424
--- Standard errno system symbols.
2525

26+
\item[glob]
27+
--- Unix shell style pathname pattern expansion.
28+
2629
\end{description}

Doc/libglob.tex

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
\section{Standard Module \sectcode{glob}}
2+
\stmodindex{glob}
3+
\renewcommand{\indexsubitem}{(in module glob)}
4+
5+
The \code{glob} module finds all the pathnames matching a specified
6+
pattern according to the rules used by the \UNIX{} shell. No tilde
7+
expansion is done, but \verb\*\, \verb\?\, and character ranges
8+
expressed with \verb\[]\ will be correctly matched. This is done by
9+
using the \code{os.listdir()} and \code{fnmatch.fnmatch()} functions
10+
in concert, and not by actually invoking a subshell. (For tilde and
11+
shell variable expansion, use \code{os.path.expanduser(}) and
12+
\code{os.path.expandvars()}.)
13+
14+
\begin{funcdesc}{glob}{pathname}
15+
Returns a possibly-empty list of path names that match \var{pathname},
16+
which must be a string containing a path specification.
17+
\var{pathname} can be either absolute (like
18+
\file{/usr/src/Python1.4/Makefile}) or relative (like
19+
\file{../../Tools/*.gif}), and can contain shell-style wildcards.
20+
\end{funcdesc}
21+
22+
For example, consider a directory containing only the following files:
23+
\file{1.gif}, \file{2.txt}, and \file{card.gif}. \code{glob.glob()}
24+
will produce the following results. Notice how any leading components
25+
of the path are preserved.
26+
27+
\begin{verbatim}
28+
>>> import glob
29+
>>> glob.glob('./[0-9].*')
30+
['./1.gif', './2.txt']
31+
>>> glob.glob('*.gif')
32+
['1.gif', 'card.gif']
33+
>>> glob.glob('?.gif')
34+
['1.gif']
35+
\end{verbatim}

Doc/libundoc.tex

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ \section{Miscellaneous useful utilities}
5353

5454
Some of these are very old and/or not very robust; marked with ``hmm''.
5555

56-
glob.py -- filename globbing (high level interface)
57-
5856
fnmatch.py -- filename globbing (low level interface)
5957

6058
calendar.py -- Calendar printing functions

0 commit comments

Comments
 (0)