Deutsch English Français Italiano |
<mailman.6.1714852629.3326.python-list@python.org> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!3.eu.feeder.erje.net!feeder.erje.net!news.in-chemnitz.de!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: 2QdxY4RzWzUUiLuE@potatochowder.com Newsgroups: comp.lang.python Subject: Re: how to discover what values produced an exception? Date: Sat, 4 May 2024 15:33:00 -0400 Lines: 36 Message-ID: <mailman.6.1714852629.3326.python-list@python.org> References: <8734qz9ey0.fsf@tudado.org> <ZjaNbCKXwgqDOC8R@anomaly> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.uni-berlin.de U/m+gcItBuC3j7UqUXJsfAE4rLnWlOkOWKG6yaErtF3g== Cancel-Lock: sha1:wJAuzhvLkYUYYLWzFN0dTO4pfsw= sha256:tDChsIwkIEXwsvbx0jOXZHj/F0dcsdMdyne4zQDNp1s= Return-Path: <2QdxY4RzWzUUiLuE@potatochowder.com> X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org Authentication-Results: mail.python.org; dkim=pass reason="2048-bit key; unprotected key" header.d=potatochowder.com header.i=@potatochowder.com header.b=gr608v3e; dkim-adsp=pass; dkim-atps=neutral X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'this:': 0.03; 'def': 0.04; 'traceback': 0.04; '(most': 0.05; 'last):': 0.05; 'cases.': 0.09; 'subject:how': 0.09; 'typeerror:': 0.09; 'from:addr:2qdxy4rzwzuuilue': 0.16; 'from:addr:potatochowder.com': 0.16; 'received:136.243': 0.16; 'received:172.58': 0.16; 'received:www458.your-server.de': 0.16; 'received:your-server.de': 0.16; 'refuse': 0.16; 'run-time': 0.16; 'subject:values': 0.16; 'subject:what': 0.16; 'useful.': 0.16; 'wrote:': 0.16; 'python': 0.16; 'values': 0.17; 'to:addr:python-list': 0.20; 'problem,': 0.22; 'received:de': 0.23; "isn't": 0.27; 'function': 0.27; '>>>': 0.28; 'printed': 0.28; "doesn't": 0.32; '"",': 0.32; 'python- list': 0.32; 'received:136': 0.32; "i'm": 0.33; 'printing': 0.34; 'header:In-Reply-To:1': 0.34; 'those': 0.36; 'lists': 0.37; "it's": 0.37; 'file': 0.38; 'could': 0.38; 'least': 0.39; 'safe': 0.39; 'something': 0.40; 'involved': 0.63; 'similar': 0.65; 'types': 0.67; 'knowing': 0.71; 'discover': 0.80; 'received:88': 0.84; 'caused': 0.86 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=potatochowder.com; s=default2305; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:To:From:Date:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=fWc7axUUHiBV+kb9rjkm7QuIg+tUXX0RzeE6l8VzP6k=; b=gr608v3eVWj8ZvOAcHACH5ztT6 3ZuXGtBNtmphLXBGQcIpUVz7Fe01xz6pE6NYWlM2pdPNc9zi5DX3BLMz5vpktgaiAfcpFpCcWH4h/ u2sar7ptcWDudCgisF4cwnJPRrC9R+accJiXubRDjv5tRMkf4jt9ZvhFFI7hVlVcSzk/5xSZZK9j+ ZDftlgwA6SR0tMauezEDHbfL75Kfk3Mkk4ZeHJgECENGbEyUWtqi/y4WYLHLQozxM2mCets8Yfork N+miC28kLMWBv9MzOXspCBbUju3JviatYSpru3sAQDksfgBd7F1MGJFy99wFzzdVgiO+Lmcve/ioy NHTwleKg==; Mail-Followup-To: python-list@python.org Content-Disposition: inline In-Reply-To: <8734qz9ey0.fsf@tudado.org> X-Authenticated-Sender: 2QdxY4RzWzUUiLuE@potatochowder.com X-Virus-Scanned: Clear (ClamAV 0.103.10/27265/Sat May 4 10:23:33 2024) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.39 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: <https://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> X-Mailman-Original-Message-ID: <ZjaNbCKXwgqDOC8R@anomaly> X-Mailman-Original-References: <8734qz9ey0.fsf@tudado.org> Bytes: 5430 On 2024-05-03 at 10:56:39 -0300, Johanne Fairchild via Python-list <python-list@python.org> wrote: > How to discover what values produced an exception? Or perhaps---why > doesn't the Python traceback show the values involved in the TypeError? > For instance: > > --8<-------------------------------------------------------->8--- > >>> (0,0) < 4 > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > TypeError: '<' not supported between instances of 'tuple' and 'int' > --8<-------------------------------------------------------->8--- > > It could have said something like: > > --8<-------------------------------------------------------->8--- > TypeError: '<' not supported between instances of 'tuple' and 'int' > in (0,0) < 4. > --8<-------------------------------------------------------->8--- > > We would know which were the values that caused the problem, which would > be very helpful. I'm not disagreeing that knowing the values could be useful in many cases. In the general case, though, it's not practical. Consider a function like this: def f(x, y): return g(x) < h(y) The printed values of x, y, g(x), and h(y) could all be millions of (or more) glyphs. Worse, one or more of those values could contain circular lists or similar structures. And h or g could have changed x or y. In summary, printing run-time values isn't always safe or useful. At least printing the types is safe. In the face of ambiguity, refuse to guess.