[Python-checkins] cpython (merge 3.2 -> default): merge from 3.2 - Fix closes Issue12697 - Update the usage syntax of timeit

senthil.kumaran python-checkins at python.org
Sat Aug 6 07:38:00 CEST 2011


http://hg.python.org/cpython/rev/46b801545126
changeset:   71759:46b801545126
parent:      71755:aea6f588230b
parent:      71758:87de58db3d40
user:        Senthil Kumaran <senthil at uthcode.com>
date:        Sat Aug 06 13:37:37 2011 +0800
summary:
  merge from 3.2 - Fix closes Issue12697 - Update the usage syntax of timeit module in the docs.

files:
  Doc/library/timeit.rst |  12 ++++++------
  1 files changed, 6 insertions(+), 6 deletions(-)


diff --git a/Doc/library/timeit.rst b/Doc/library/timeit.rst
--- a/Doc/library/timeit.rst
+++ b/Doc/library/timeit.rst
@@ -191,13 +191,13 @@
 :keyword:`try`/:keyword:`except` to test for missing and present object
 attributes. ::
 
-   % timeit.py 'try:' '  str.__bool__' 'except AttributeError:' '  pass'
+   $ python -m timeit 'try:' '  str.__bool__' 'except AttributeError:' '  pass'
    100000 loops, best of 3: 15.7 usec per loop
-   % timeit.py 'if hasattr(str, "__bool__"): pass'
+   $ python -m timeit 'if hasattr(str, "__bool__"): pass'
    100000 loops, best of 3: 4.26 usec per loop
-   % timeit.py 'try:' '  int.__bool__' 'except AttributeError:' '  pass'
+   $ python -m timeit 'try:' '  int.__bool__' 'except AttributeError:' '  pass'
    1000000 loops, best of 3: 1.43 usec per loop
-   % timeit.py 'if hasattr(int, "__bool__"): pass'
+   $ python -m timeit 'if hasattr(int, "__bool__"): pass'
    100000 loops, best of 3: 2.23 usec per loop
 
 ::
@@ -238,10 +238,10 @@
 ``setup`` parameter which contains an import statement::
 
    def test():
-       "Stupid test function"
+       """Stupid test function"""
        L = [i for i in range(100)]
 
-   if __name__=='__main__':
+   if __name__ == '__main__':
        from timeit import Timer
        t = Timer("test()", "from __main__ import test")
        print(t.timeit())

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list