Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2e01535

Browse files
committed
Fix closes Issue12697 - Update the usage syntax of timeit module in the docs.
1 parent a3b2316 commit 2e01535

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

Doc/library/timeit.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,13 @@ interface) that compare the cost of using :func:`hasattr` vs.
191191
:keyword:`try`/:keyword:`except` to test for missing and present object
192192
attributes. ::
193193

194-
% timeit.py 'try:' ' str.__bool__' 'except AttributeError:' ' pass'
194+
$ python -m timeit 'try:' ' str.__bool__' 'except AttributeError:' ' pass'
195195
100000 loops, best of 3: 15.7 usec per loop
196-
% timeit.py 'if hasattr(str, "__bool__"): pass'
196+
$ python -m timeit 'if hasattr(str, "__bool__"): pass'
197197
100000 loops, best of 3: 4.26 usec per loop
198-
% timeit.py 'try:' ' int.__bool__' 'except AttributeError:' ' pass'
198+
$ python -m timeit 'try:' ' int.__bool__' 'except AttributeError:' ' pass'
199199
1000000 loops, best of 3: 1.43 usec per loop
200-
% timeit.py 'if hasattr(int, "__bool__"): pass'
200+
$ python -m timeit 'if hasattr(int, "__bool__"): pass'
201201
100000 loops, best of 3: 2.23 usec per loop
202202

203203
::
@@ -238,10 +238,10 @@ To give the :mod:`timeit` module access to functions you define, you can pass a
238238
``setup`` parameter which contains an import statement::
239239

240240
def test():
241-
"Stupid test function"
241+
"""Stupid test function"""
242242
L = [i for i in range(100)]
243243

244-
if __name__=='__main__':
244+
if __name__ == '__main__':
245245
from timeit import Timer
246246
t = Timer("test()", "from __main__ import test")
247247
print(t.timeit())

0 commit comments

Comments
 (0)