summaryrefslogtreecommitdiffstats
path: root/Lib/timeit.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-10-09 22:05:45 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-10-09 22:05:45 (GMT)
commitde0559998fef231efc9ecbdef5b3a195d4eaa28d (patch)
tree235b05866ae52f80d81f2953c663d74f1de6dae1 /Lib/timeit.py
parent0c8bee639368324b750176ee171cadd33847f18e (diff)
downloadcpython-de0559998fef231efc9ecbdef5b3a195d4eaa28d.zip
cpython-de0559998fef231efc9ecbdef5b3a195d4eaa28d.tar.gz
cpython-de0559998fef231efc9ecbdef5b3a195d4eaa28d.tar.bz2
replace callable()
Diffstat (limited to 'Lib/timeit.py')
-rw-r--r--Lib/timeit.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/timeit.py b/Lib/timeit.py
index 9054243..052f140 100644
--- a/Lib/timeit.py
+++ b/Lib/timeit.py
@@ -126,7 +126,7 @@ class Timer:
if isinstance(setup, basestring):
setup = reindent(setup, 4)
src = template % {'stmt': stmt, 'setup': setup}
- elif callable(setup):
+ elif hasattr(setup, '__call__'):
src = template % {'stmt': stmt, 'setup': '_setup()'}
ns['_setup'] = setup
else:
@@ -135,13 +135,13 @@ class Timer:
code = compile(src, dummy_src_name, "exec")
exec code in globals(), ns
self.inner = ns["inner"]
- elif callable(stmt):
+ elif hasattr(stmt, '__call__'):
self.src = None
if isinstance(setup, basestring):
_setup = setup
def setup():
exec _setup in globals(), ns
- elif not callable(setup):
+ elif not hasattr(setup, '__call__'):
raise ValueError("setup is neither a string nor callable")
self.inner = _template_func(setup, stmt)
else: