From: Fred Drake Date: Tue, 30 Dec 2003 23:01:19 +0000 (+0000) Subject: minor cleanup of example X-Git-Tag: v2.4a1~1023 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ea49de34c9e55f7356c71765f3674d140f348ff6;p=thirdparty%2FPython%2Fcpython.git minor cleanup of example --- diff --git a/Doc/lib/libuser.tex b/Doc/lib/libuser.tex index 0d0ecb680913..4e915a22c88c 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.