Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #103769
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: common mistakes in this simple program |
| Date | Mon, 29 Feb 2016 16:39:37 -0700 |
| Lines | 14 |
| Message-ID | <mailman.50.1456789219.20602.python-list@python.org> (permalink) |
| References | <CALwzidn8-HDrGSqZT2ODxhdNYL7yFt5hdmC8RnB4WC=gkD4Wtg@mail.gmail.com> <20160229231421.GA71350@cskk.homeip.net> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de FUbHY2fldN88dSc6a1MTMglXTlRPGCEV8umsne+CWW5g== |
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.013 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; 'received:209.85.223': 0.03; 'context': 0.05; '%s",': 0.09; 'argument:': 0.09; 'exception': 0.13; '2016': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'simpson': 0.16; 'subject:program': 0.16; 'subject:simple': 0.16; 'wrote:': 0.16; 'handles': 0.20; 'meant': 0.22; 'pass': 0.22; 'feb': 0.23; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; 'example': 0.26; 'equivalent': 0.27; 'message- id:@mail.gmail.com': 0.27; 'went': 0.28; 'code': 0.30; 'another': 0.32; 'received:google.com': 0.35; 'but': 0.36; 'received:209.85': 0.36; 'keyword': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'things': 0.38; 'received:209': 0.38; 'log': 0.38; 'files': 0.38; 'to:addr:python.org': 0.40; 'here:': 0.63; 'cameron': 0.66; 'accompanying': 0.67; 'remark': 0.84; 'subject:common': 0.84; 'to:name:python': 0.84; 'subject:this': 0.85 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=Bj22fsyDwQP7f0AvH01PCCXav0hDg4QwUOiZvZgTpDA=; b=iVqF1hqgHwBL9zb65NzHuA1oDzkYpgwVFGOKL8pVSzG6RM2E86+vJB1H5tm1ZksMvn AyKMt5zJEN66OFANnKr56exkYBOgLSL5LtiF2YqsrzYId/XBygqHY1WVL4Nabbmiz+7Y tVcKucr4cfQFuaMxl8lkNfR8P7Gs0goU61evOm2fgD8zJVt3AxFoankYds/uG+G73IND eT7CJoz9EG9rz16DcBofsx0/iWhnVtHcW6AZIin1vO2vQ6mKYLz6FYggv9aeh3o5Hu4y tkQdA1d8N+kQDJYLqDDFvSvaSJdcUk4KfNfumucdHb/xnK0Bch4d7erhM5nqWtwqOEGC hlxw== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=Bj22fsyDwQP7f0AvH01PCCXav0hDg4QwUOiZvZgTpDA=; b=L/llNwiuzUjZAICx7bQY7IMxQgs/vUEC0Irnk4nzHCsKocLh1dHzm8wZKgO00qEzdR Ri1nL2m8mcf2sKyg4RVka6DcWy7pBWgzPQ+QUi+E+ozS68Qt5dBVYYLJTCbFwmbrmY/i 3rJOhUwKz2ifbkAzBj12VbZ/kg1zknvJIX/z2opWs/IqA63awlplK4HretNq6MUWPzBH jnUid8FaQRjE65u19xnVZiOUnGhrJffJDUXFu+O0Hk3jZJF0slh8EKkNVNYC4MsWVFm+ gEu0b48pt2B9DtTPfM3wBK6Q4jIYmaivI7MhFR+MixXGdz+eLTDP5O7b/90AZ5G0r+qc G7zQ== |
| X-Gm-Message-State | AG10YOQKjOcVrwVuymJptAsiLywhJHo+tNRJVCKyndHsWvRHsmypS4dTOT8wIusPZr6kmhrxcUTg6Vqno1ZJuA== |
| X-Received | by 10.107.185.214 with SMTP id j205mr22405884iof.111.1456789216724; Mon, 29 Feb 2016 15:40:16 -0800 (PST) |
| In-Reply-To | <20160229231421.GA71350@cskk.homeip.net> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:103769 |
Show key headers only | View raw
On Mon, Feb 29, 2016 at 4:14 PM, Cameron Simpson <cs@zip.com.au> wrote:
> Another remark here: if you're going to log, log the exception as well:
>
> logging.error("something went wrong: %s", e)
>
> Ian's example code is nice and simple to illustrate "log and then reraise"
> but few things are as annoying as log files reciting "something went wrong"
> or the equivalent without any accompanying context information.
The proper way to pass in the exception is as a keyword argument:
logging.error("something went wrong", exc_info=e)
But I actually meant to use logging.exception, which handles this automatically.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: common mistakes in this simple program Ian Kelly <ian.g.kelly@gmail.com> - 2016-02-29 16:39 -0700
csiph-web