summaryrefslogtreecommitdiffstats
path: root/Doc/lib
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2003-12-30 23:01:19 (GMT)
committerFred Drake <fdrake@acm.org>2003-12-30 23:01:19 (GMT)
commitea49de34c9e55f7356c71765f3674d140f348ff6 (patch)
tree74adea3d20b81d279a8b69f18338e76b89ae7967 /Doc/lib
parentff381e13e0af4026bb689117a60b596f6488943c (diff)
downloadcpython-ea49de34c9e55f7356c71765f3674d140f348ff6.zip
cpython-ea49de34c9e55f7356c71765f3674d140f348ff6.tar.gz
cpython-ea49de34c9e55f7356c71765f3674d140f348ff6.tar.bz2
minor cleanup of example
Diffstat (limited to 'Doc/lib')
-rw-r--r--Doc/lib/libuser.tex10
1 files changed, 6 insertions, 4 deletions
diff --git a/Doc/lib/libuser.tex b/Doc/lib/libuser.tex
index 0d0ecb6..4e915a2 100644
--- a/Doc/lib/libuser.tex
+++ b/Doc/lib/libuser.tex
@@ -48,12 +48,14 @@ level can look for a variable \code{user.spam_verbose}, as follows:
\begin{verbatim}
import user
-try:
- verbose = user.spam_verbose # user's verbosity preference
-except AttributeError:
- verbose = 0 # default verbosity
+
+verbose = bool(getattr(user, "spam_verbose", 0))
\end{verbatim}
+(The three-argument form of \function{getattr()} is used in case
+the user has not defined \code{spam_verbose} in their
+\file{.pythonrc.py} file.)
+
Programs with extensive customization needs are better off reading a
program-specific customization file.