title: timing block of code in Python without putting it in a function
body: <p>I'd like to time a block of code without putting it in a separate function. for example:</p>
  
  <pre><code>def myfunc:
    # some code here
    t1 = time.time()
    # block of code to time here
    t2 = time.time()
    print "Code took %s seconds." %(str(t2-t1))
  </code></pre>
  
  <p>however, I'd like to do this with the timeit module in a cleaner way, but I don't want to make a separate function for the block of code.</p>
  
  <p>thanks.</p>