summaryrefslogtreecommitdiffstats
path: root/Lib/timeit.py
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2011-10-28 12:45:05 (GMT)
committerFlorent Xicluna <florent.xicluna@gmail.com>2011-10-28 12:45:05 (GMT)
commit5d1155c08edf7f53eca804b2b6538636c2dfe711 (patch)
treedcb2cf857c20dce837c82de7aea432ccf9a41355 /Lib/timeit.py
parentf99e4b5dbef57e13dd603dcc0edd9b7318f08c28 (diff)
downloadcpython-5d1155c08edf7f53eca804b2b6538636c2dfe711.zip
cpython-5d1155c08edf7f53eca804b2b6538636c2dfe711.tar.gz
cpython-5d1155c08edf7f53eca804b2b6538636c2dfe711.tar.bz2
Closes #13258: Use callable() built-in in the standard library.
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 461c891..1ae59e0 100644
--- a/Lib/timeit.py
+++ b/Lib/timeit.py
@@ -127,7 +127,7 @@ class Timer:
if isinstance(setup, str):
setup = reindent(setup, 4)
src = template % {'stmt': stmt, 'setup': setup}
- elif hasattr(setup, '__call__'):
+ elif callable(setup):
src = template % {'stmt': stmt, 'setup': '_setup()'}
ns['_setup'] = setup
else:
@@ -136,13 +136,13 @@ class Timer:
code = compile(src, dummy_src_name, "exec")
exec(code, globals(), ns)
self.inner = ns["inner"]
- elif hasattr(stmt, '__call__'):
+ elif callable(stmt):
self.src = None
if isinstance(setup, str):
_setup = setup
def setup():
exec(_setup, globals(), ns)
- elif not hasattr(setup, '__call__'):
+ elif not callable(setup):
raise ValueError("setup is neither a string nor callable")
self.inner = _template_func(setup, stmt)
else: