Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #41329

Re: PyWart: NameError trackbacks are superfluous

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin3!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <oscar.j.benjamin@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'broken': 0.03; 'interpreter': 0.04; 'guido': 0.05; 'arguments': 0.07; 'layers': 0.07; 'python': 0.09; 'exist.': 0.09; 'logic': 0.09; 'lookup': 0.09; 'nameerror:': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; '*real*': 0.16; 'bugs,': 0.16; 'cc:name:python list': 0.16; 'nameerror': 0.16; 'variables;': 0.16; 'wrote:': 0.17; 'module': 0.19; 'trying': 0.21; 'do.': 0.21; 'trace': 0.22; 'defined': 0.22; 'cc:2**0': 0.23; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; '(most': 0.27; 'question': 0.27; 'message-id:@mail.gmail.com': 0.27; 'run': 0.28; 'occurred': 0.29; "skip:' 10": 0.30; 'e.g.': 0.30; 'function': 0.30; 'error': 0.30; 'helpful': 0.30; 'code': 0.31; 'file': 0.32; 'johnson': 0.32; 'function.': 0.33; 'that!': 0.33; 'traceback': 0.33; 'received:google.com': 0.34; 'sometimes': 0.35; 'useful': 0.36; 'thank': 0.36; 'skip:p 20': 0.36; 'does': 0.37; 'why': 0.37; 'passed': 0.37; 'subject:: ': 0.38; 'nothing': 0.38; 'shows': 0.38; 'gives': 0.39; 'your': 0.60; 'different': 0.63; 'information': 0.63; 'more': 0.63; 'within': 0.64; 'generated.': 0.65; 'hints': 0.65; 'levels': 0.66; '2013': 0.84; 'detecting': 0.84; 'oscar': 0.84; 'rick': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; bh=eGr4dffqcjj2fk+uX4VkrNa/nMyOnj/R7K5WNa2RZ6o=; b=XMp+qcZPGVtcwzQaQjSmxkFyTw1tN7ICLmbFMY1CjVAz7zNVEFjD7OGjUiPDLCYVNH nhrXNDpNl7qJUpu+K+mUbfraVpTvcr5PnDy3mxVOR3tTRCz0FBA/PfwTAoiLiA1p8RCY MiXz6b3SzFGNCPWOFYI+w58jXJdVgp40T68wnkDyPB/PJ7e3aE+cidsmQj6oiPtIeW4Z WW0UEBvdf4hpRxyJK59bPVtEYZdSyZup6JVeSR+s1HGY1WURFLVXhnR5XiISwQF62qHj RoBGb2PdkwSrKxcK3pKpLV2CMBo3BHIBLe1MVQMgS6c6rt2XQRH8EEZP94vsxSzfTT3W eBqg==
X-Received by 10.52.71.235 with SMTP id y11mr11100649vdu.43.1363468795038; Sat, 16 Mar 2013 14:19:55 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <e6e760f7-eb3a-41c8-b52c-f14ee73aabb1@googlegroups.com>
References <e6e760f7-eb3a-41c8-b52c-f14ee73aabb1@googlegroups.com>
From Oscar Benjamin <oscar.j.benjamin@gmail.com>
Date Sat, 16 Mar 2013 21:19:34 +0000
Subject Re: PyWart: NameError trackbacks are superfluous
To Rick Johnson <rantingrickjohnson@gmail.com>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
Cc Python List <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3372.1363468797.2939.python-list@python.org> (permalink)
Lines 43
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1363468797 news.xs4all.nl 6841 [2001:888:2000:d::a6]:37682
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:41329

Show key headers only | View raw


On 16 March 2013 18:27, Rick Johnson <rantingrickjohnson@gmail.com> wrote:
>
> Sometimes many levels of trace messages can be helpful when detecting bugs, however, in the case of NameErrors,  these "nuggets" ejected from deep within the bowls of the Python interpreter are nothing more than steaming piles of incomprehensible crap!
>
> We don't need multiple layers of traces for NameErrors. Python does not have *real* global variables; and thank Guido for that! All we need to know is which module the error occurred in AND which line of that module contains the offensive lookup of a name that does not exist.
[SNIP]

NameErrors can occur conditionally depending on e.g. the arguments to
a function. Consider the following script:

  # tmp.py
  def broken(x):
      if x > 2:
          print(x)
      else:
          print(undefined_name)

  broken(1)

When run it gives a NameError with a traceback:

$ python tmp.py
Traceback (most recent call last):
  File "tmp3.py", line 8, in <module>
    broken(1)
  File "tmp3.py", line 6, in broken
    print(undefined_name)
NameError: global name 'undefined_name' is not defined

The traceback shows the arguments passed to the broken function that
caused the NameError to be generated. Different arguments would not
have generated the NameError. This information can be useful if the
logic of the function in question is complicated. It also hints at why
you were calling the function and what your code is trying to do.


Oscar

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

PyWart: NameError trackbacks are superfluous Rick Johnson <rantingrickjohnson@gmail.com> - 2013-03-16 11:27 -0700
  Re: PyWart: NameError trackbacks are superfluous Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-03-16 21:19 +0000
    Re: PyWart: NameError trackbacks are superfluous Rick Johnson <rantingrickjohnson@gmail.com> - 2013-03-16 15:39 -0700
      Re: PyWart: NameError trackbacks are superfluous Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-03-16 23:29 +0000
        Re: PyWart: NameError trackbacks are superfluous Rick Johnson <rantingrickjohnson@gmail.com> - 2013-03-16 16:50 -0700
          Re: PyWart: NameError trackbacks are superfluous Chris Angelico <rosuav@gmail.com> - 2013-03-17 11:00 +1100
      Re: PyWart: NameError trackbacks are superfluous Tim Chase <python.list@tim.thechases.com> - 2013-03-16 18:36 -0500
      Re: PyWart: NameError trackbacks are superfluous Chris Angelico <rosuav@gmail.com> - 2013-03-17 10:48 +1100
    Re: PyWart: NameError trackbacks are superfluous Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-16 23:48 +0000
      Re: PyWart: NameError trackbacks are superfluous Chris Angelico <rosuav@gmail.com> - 2013-03-17 10:59 +1100
      Re: PyWart: NameError trackbacks are superfluous Rick Johnson <rantingrickjohnson@gmail.com> - 2013-03-16 17:11 -0700
        Re: PyWart: NameError trackbacks are superfluous Michael Torrie <torriem@gmail.com> - 2013-03-16 19:58 -0600
          Re: PyWart: NameError trackbacks are superfluous Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-17 03:14 +0000
            Re: PyWart: NameError trackbacks are superfluous Chris Angelico <rosuav@gmail.com> - 2013-03-17 14:19 +1100
            Re: PyWart: NameError trackbacks are superfluous Benjamin Kaplan <benjamin.kaplan@case.edu> - 2013-03-16 21:13 -0700
  Re: PyWart: NameError trackbacks are superfluous Jason Swails <jason.swails@gmail.com> - 2013-03-17 17:22 -0400

csiph-web