Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 111305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:21:50+00:00 2026-05-11T02:21:50+00:00

In this blog article they use the construct: @measured def some_func(): #… # Presumably

  • 0

In this blog article they use the construct:

  @measured   def some_func():     #...   # Presumably outputs something like 'some_func() is finished in 121.333 s' somewhere 

This @measured directive doesn’t seem to work with raw python. What is it?

UPDATE: I see from Triptych that @something is valid, but is where can I find @measured, is it in a library somewhere, or is the author of this blog using something from his own private code base?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T02:21:50+00:00Added an answer on May 11, 2026 at 2:21 am

    @measured decorates the some_func() function, using a function or class named measured. The @ is the decorator syntax, measured is the decorator function name.

    Decorators can be a bit hard to understand, but they are basically used to either wrap code around a function, or inject code into one.

    For example the measured function (used as a decorator) is probably implemented like this…

    import time  def measured(orig_function):     # When you decorate a function, the decorator func is called     # with the original function as the first argument.     # You return a new, modified function. This returned function     # is what the to-be-decorated function becomes.      print 'INFO: This from the decorator function'     print 'INFO: I am about to decorate %s' % (orig_function)      # This is what some_func will become:     def newfunc(*args, **kwargs):         print 'INFO: This is the decorated function being called'          start = time.time()          # Execute the old function, passing arguments         orig_func_return = orig_function(*args, **kwargs)         end = time.time()          print 'Function took %s seconds to execute' % (end - start)         return orig_func_return # return the output of the original function      # Return the modified function, which..     return newfunc  @measured def some_func(arg1):     print 'This is my original function! Argument was %s' % arg1  # We call the now decorated function.. some_func(123)  #.. and we should get (minus the INFO messages): This is my original function! Argument was 123 # Function took 7.86781311035e-06 to execute 

    The decorator syntax is just a shorter and neater way of doing the following:

    def some_func():     print 'This is my original function!'  some_func = measured(some_func) 

    There are some decorators included with Python, for example staticmethod – but measured is not one of them:

    >>> type(measured) Traceback (most recent call last):   File '<stdin>', line 1, in <module> NameError: name 'measured' is not defined 

    Check the projects import statements to see where the function or class is coming from. If it uses from blah import * you’ll need to check all of those files (which is why import * is discouraged), or you could just do something like grep -R def measured *

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

just was reading this article http://highscalability.com/blog/2010/3/23/digg-4000-performance-increase-by-sorting-in-php-rather-than.html And found this nice article http://wiki.apache.org/cassandra/DataModel I just
I was reading this article on Coding Horror: http://www.codinghorror.com/blog/2008/04/setting-up-subversion-on-windows.html I went to the downloads
I am following this article: http://www.lunametrics.com/blog/2011/12/01/automatic-cross-domain-tracking-revisited/ which leads me to put the following in
I was reading about data driven testing using mbunit from this article. http://blog.benhall.me.uk/2007/04/mbunit-datafixture-data-driven-unit.html I
Just finished reading this blog post: http://www.skorks.com/2010/03/an-interview-question-that-prints-out-its-own-source-code-in-ruby/ In it, the author argues the case
This blog post of December 2008 says that rubygems is broken on Debian-based systems.
This blog says Include Return Statements with in the Function/Method. How it improves performance
In this blog, http://www.bswebdev.com/2008/12/javascript-change-input-box-type-to-password/ I have found the following snippets for fixing change input
This question is in regards to this blog entry. https://blog.stackoverflow.com/2008/07/easy-background-tasks-in-aspnet/ All the way at
I have following this blog in setting Xvfb in my ubuntu environment: http://corpocrat.com/2008/08/19/how-to-install-xvfb-x11-server-in-linux-server/ So

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.