Mercurial > cpython-lru_cache-weakref
diff Doc/lib/libuser.tex @ 31288:fd4cbbeace79 legacy-trunk
minor cleanup of example
| author | Fred Drake <fdrake@acm.org> |
|---|---|
| date | Tue, 30 Dec 2003 23:01:19 +0000 |
| parents | 33b4357aebb8 |
| children | ac192f89c109 |
line wrap: on
line diff
--- a/Doc/lib/libuser.tex Tue Dec 30 22:51:32 2003 +0000 +++ b/Doc/lib/libuser.tex Tue Dec 30 23:01:19 2003 +0000 @@ -48,12 +48,14 @@ \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.
