summaryrefslogtreecommitdiff
path: root/pystache
diff options
context:
space:
mode:
authorChris Jerdonek <chris.jerdonek@gmail.com>2012-05-02 20:45:06 -0700
committerChris Jerdonek <chris.jerdonek@gmail.com>2012-05-02 20:45:06 -0700
commit1ef4f9062f9b82a58de66dbde0df7d7fd444e60a (patch)
tree06da1125c2c9cd76cfb0e73d00430f649d0f57d0 /pystache
parentd570f70afec246fac270dd361ce123ba9514c1df (diff)
downloadpystache-1ef4f9062f9b82a58de66dbde0df7d7fd444e60a.tar.gz
Replaced the context module's use of _is_callable() with Python's built-in callable().
Diffstat (limited to 'pystache')
-rw-r--r--pystache/context.py9
1 files changed, 3 insertions, 6 deletions
diff --git a/pystache/context.py b/pystache/context.py
index e2740f0..cbc8158 100644
--- a/pystache/context.py
+++ b/pystache/context.py
@@ -22,11 +22,6 @@ class NotFound(object):
_NOT_FOUND = NotFound()
-# TODO: share code with template.check_callable().
-def _is_callable(obj):
- return hasattr(obj, '__call__')
-
-
# TODO: document what a "context" is as opposed to a context stack.
def _get_value(context, key):
"""
@@ -54,7 +49,9 @@ def _get_value(context, key):
# are considered objects by the test above.
if hasattr(context, key):
attr = getattr(context, key)
- if _is_callable(attr):
+ # TODO: consider using EAFP here instead.
+ # http://docs.python.org/glossary.html#term-eafp
+ if callable(attr):
return attr()
return attr