NameError: name Timer is not defined
Question: I have a small python program written for python 2.7.3:

    
    
    import time
    def fun():
        print('Hi')
    for i in range(3):
        Timer(i, fun).start()
    

When I run it, I get the error:

`NameError: name 'Timer' is not defined`

How can I find out which module supports this functionality?


Answer: `Timer` is in the `timeit` module, not `time`. And to call it like you want
to, you would have to `from timeit import Timer`, not just `import timeit`. If
you just declare `import timeit`, then you would have to write `timeit.Timer`
instead of `Timer` everywhere in the code.

