The Ruby or Python `NameError` exception.
In Ruby, NameError
exceptions are raised when a given name is invalid or undefined. For example:
puts pancakes
will raise a NameError
if there is no pancakes
method or variable. You will also get a NameError
if you try to define a constant whose first letter is not a capital:
SomeModule.const_set :pancakes, 11
In Python, a NameError
is raised when:
... a local or global name is not found. This applies only to unqualified names. The associated value is an error message that includes the name that could not be found.
An example is below in which a NameError
is raised because x
is not defined in the current scope:
>>> x
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'x' is not defined
>>>