Class Undefined
object --+
|
Undefined
Represents a reference to an undefined variable.
Unlike the Python runtime, template expressions can refer to an undefined
variable without causing a NameError
to be raised. The result will be an
instance of the Undefined class, which is treated the same as False in
conditions, but raise an exception on any other operation:
>>> foo = Undefined('foo')
>>> bool(foo)
False
>>> list(foo)
[]
>>> print(foo)
undefined
However, calling an undefined variable, or trying to access an attribute
of that variable, will raise an exception that includes the name used to
reference that undefined variable.
>>> foo('bar')
Traceback (most recent call last):
...
UndefinedError: "foo" not defined
>>> foo.bar
Traceback (most recent call last):
...
UndefinedError: "foo" not defined
|
__init__(self,
name,
owner=UNDEFINED)
Initialize the object. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__setattr__ ,
__sizeof__ ,
__subclasshook__
|
|
__length_hint__ = None
hash(x)
|
Inherited from object :
__class__
|
__init__(self,
name,
owner=UNDEFINED)
(Constructor)
|
|
Initialize the object.
- Parameters:
name - the name of the reference
owner - the owning object, if the variable is accessed as a member
- Overrides:
object.__init__
|
__repr__(self)
(Representation operator)
|
|
repr(x)
- Overrides:
object.__repr__
- (inherited documentation)
|
__str__(self)
(Informal representation operator)
|
|
str(x)
- Overrides:
object.__str__
- (inherited documentation)
|