Decorator to measure execution time of a function
I'd recommend the timeit module when measuring the execution time of functions. AFAIK, timeit disables the garbage collector for the duration of the test, which might give you better results overall.

From here:


  timeit is more accurate, for three reasons:
  
  
  it repeats the tests many times to eliminate the influence of other tasks on your machine, such as disk flushing and OS scheduling.
  it disables the garbage collector to prevent that process from skewing the results by scheduling a collection run at an inopportune
  moment.
  it picks the most accurate timer for your OS, time.time or time.clock, see
  timeit.default_timer.
  


On the other side, a timing decorator is really useful because you can use annotations to sprinkle the timing around your code rather than making your code messy with timing logic everywhere. So yes, related to one of your questions, the code is useful.

Now, on the pythonic question, IMO:


you have too many comments which unfortunately didn't add any value to your code. Remove them.
your inner function could also be renamed to something more intuitive like wrapper.
function is also not the best choice when it comes to naming conventions as it might shadow the built-in function
use 2 newlines between imports and methods
the indentation should be a multiple of 4 (spaces)
use triple double quotes for your module docstring




In Python, there're already some useful modules to help you with this. For example, in functools you have the wraps decorator. This takes a function used in a decorator and adds the functionality of copying over the function name, docstring, arguments list, etc. And since wraps is itself a decorator I guess it'll make things a lot easier.



Code:

from functools import wraps
from time import time


def timing(f):
    @wraps(f)
    def wrapper(*args, **kwargs):
        start = time()
        result = f(*args, **kwargs)
        end = time()
        print 'Elapsed time: {}'.format(end-start)
        return result
    return wrapper


Usage:

@timing
def f(a):
    for _ in range(a):
        pass

print(f(2000000))


Result:


  Elapsed time: 0.0971460342407