annotate Doc/lib/liblinecache.tex @ 27998:e27f58a50737 legacy-trunk

SF bug #690377: Dud footnote reference in distutils docs
author Raymond Hettinger <python@rcn.com>
date Fri, 21 Feb 2003 02:47:09 +0000
parents c7c404b35f33
children 4dd97c37c2cc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10982
bef46ea5ef75 New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
1 \section{\module{linecache} ---
11003
086b2bc7578f Small English usage nits.
Fred Drake <fdrake@acm.org>
parents: 10982
diff changeset
2 Random access to text lines}
10982
bef46ea5ef75 New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
3
bef46ea5ef75 New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
4 \declaremodule{standard}{linecache}
15467
d7864345b1c8 Update Moshe Zadka's email address to one works and might last a while.
Fred Drake <fdrake@acm.org>
parents: 12223
diff changeset
5 \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il}
11003
086b2bc7578f Small English usage nits.
Fred Drake <fdrake@acm.org>
parents: 10982
diff changeset
6 \modulesynopsis{This module provides random access to individual lines
086b2bc7578f Small English usage nits.
Fred Drake <fdrake@acm.org>
parents: 10982
diff changeset
7 from text files.}
10982
bef46ea5ef75 New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
8
bef46ea5ef75 New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
9
bef46ea5ef75 New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
10 The \module{linecache} module allows one to get any line from any file,
bef46ea5ef75 New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
11 while attempting to optimize internally, using a cache, the common case
11003
086b2bc7578f Small English usage nits.
Fred Drake <fdrake@acm.org>
parents: 10982
diff changeset
12 where many lines are read from a single file. This is used by the
086b2bc7578f Small English usage nits.
Fred Drake <fdrake@acm.org>
parents: 10982
diff changeset
13 \refmodule{traceback} module to retrieve source lines for inclusion in
086b2bc7578f Small English usage nits.
Fred Drake <fdrake@acm.org>
parents: 10982
diff changeset
14 the formatted traceback.
10982
bef46ea5ef75 New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
15
bef46ea5ef75 New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
16 The \module{linecache} module defines the following functions:
bef46ea5ef75 New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
17
bef46ea5ef75 New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
18 \begin{funcdesc}{getline}{filename, lineno}
bef46ea5ef75 New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
19 Get line \var{lineno} from file named \var{filename}. This function
12223
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 11003
diff changeset
20 will never throw an exception --- it will return \code{''} on errors
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 11003
diff changeset
21 (the terminating newline character will be included for lines that are
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 11003
diff changeset
22 found).
10982
bef46ea5ef75 New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
23
bef46ea5ef75 New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
24 If a file named \var{filename} is not found, the function will look
11003
086b2bc7578f Small English usage nits.
Fred Drake <fdrake@acm.org>
parents: 10982
diff changeset
25 for it in the module\indexiii{module}{search}{path} search path,
086b2bc7578f Small English usage nits.
Fred Drake <fdrake@acm.org>
parents: 10982
diff changeset
26 \code{sys.path}.
10982
bef46ea5ef75 New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
27 \end{funcdesc}
bef46ea5ef75 New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
28
bef46ea5ef75 New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
29 \begin{funcdesc}{clearcache}{}
12223
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 11003
diff changeset
30 Clear the cache. Use this function if you no longer need lines from
e82e82b3b9ad Merged changes from the 1.5.2p2 release.
Fred Drake <fdrake@acm.org>
parents: 11003
diff changeset
31 files previously read using \function{getline()}.
10982
bef46ea5ef75 New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
32 \end{funcdesc}
bef46ea5ef75 New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
33
bef46ea5ef75 New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
34 \begin{funcdesc}{checkcache}{}
11003
086b2bc7578f Small English usage nits.
Fred Drake <fdrake@acm.org>
parents: 10982
diff changeset
35 Check the cache for validity. Use this function if files in the cache
086b2bc7578f Small English usage nits.
Fred Drake <fdrake@acm.org>
parents: 10982
diff changeset
36 may have changed on disk, and you require the updated version.
10982
bef46ea5ef75 New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
37 \end{funcdesc}
bef46ea5ef75 New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
38
bef46ea5ef75 New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
39 Example:
bef46ea5ef75 New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
40
bef46ea5ef75 New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
41 \begin{verbatim}
bef46ea5ef75 New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
42 >>> import linecache
bef46ea5ef75 New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
43 >>> linecache.getline('/etc/passwd', 4)
16226
c7c404b35f33 Show '\011', '\012', and '\015' as '\t', '\n', '\r' in strings.
Ka-Ping Yee <ping@zesty.ca>
parents: 15467
diff changeset
44 'sys:x:3:3:sys:/dev:/bin/sh\n'
10982
bef46ea5ef75 New sections from Moshe Zadka <moshez@math.huji.ac.il>.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
45 \end{verbatim}