changeset 388:31dc3d18b39e stable-0.3.x

0.3.x branch: add unit test for `Undefined` checks in template expressions.
author cmlenz
date Mon, 11 Dec 2006 12:06:28 +0000
parents a52452a65cd7
children ccf00b09972c
files genshi/eval.py
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/genshi/eval.py
+++ b/genshi/eval.py
@@ -61,6 +61,15 @@
     >>> data = dict(items=[1, 2, 3])
     >>> Expression('len(items)').evaluate(data)
     3
+    
+    Undefined variables can be accessed in expressions, and evaluate to a
+    non-truth value for tests. To check whether a particular variable is
+    defined, its type can be compared to the special builtin class `Undefined`:
+    
+    >>> Expression('foo').evaluate({})
+    undefined
+    >>> Expression('type(foo) is Undefined').evaluate({})
+    True
     """
     __slots__ = ['source', 'code']
 
Copyright (C) 2012-2017 Edgewall Software