This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author cool-RR
Recipients cool-RR
Date 2013-01-25.14:42:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1359124974.58.0.158587338796.issue17032@psf.upfronthosting.co.za>
In-reply-to
Content
Every single time I see the error message `global name 'X' is not defined` I say to myself, "ah yeah, I mistyped a variable name."

But then it occurred to me, why should I have to do this mental translation from "global name not defined" to "I mistyped a variable name"?

Now, I'm not asking for the error message to say "You mistyped a variable name", because that goes too much into second-guessing the user. But can we at least drop the reference to a global name? I understand that Python first searches the local namespace, and only then in the global namespace, and if the name isn't found there then an error is raised. But that doesn't mean that the error message should just assume that the variable is supposed to be global. It's misleading to say that a variable is global when it's in fact local.

I think that the error message should just say `Variable 'X' not defined`. Maybe add a suggestion `(Typo?)` at the end.


Example:

    >>> def f():
    ...     meow = 0
    ...     return meoow
    ...
    >>> f()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "<stdin>", line 3, in f
    NameError: global name 'meoow' is not defined

I'd make the error message:

    NameError: Variable 'meoow' is not defined
History
Date User Action Args
2013-01-25 14:42:54cool-RRsetrecipients: + cool-RR
2013-01-25 14:42:54cool-RRsetmessageid: <1359124974.58.0.158587338796.issue17032@psf.upfronthosting.co.za>
2013-01-25 14:42:54cool-RRlinkissue17032 messages
2013-01-25 14:42:54cool-RRcreate