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

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
The comments section of this article: http://ayende.com/Blog/archive/2010/09/18/resolving-cross-site-scripting-issues.aspx has a very interesting comment. In it,
Our group read the widely referenced article http://blog.quantumbitdesigns.com/2008/07/22/wpf-cross-thread-collection-binding-part-4-the-grand-solution/ and wondered if any of you
I was reading this excellent article which gives an introduction to Asynchronous programming here
I have build a basic blog application, where an admin can write the article
There is a blog , powered by Wordpress, which has valid RSS feed (opens
I am working currently for a project on which several parts of the website
Ok, I have a model that is very simple: ServiceType(id: integer, title: string, duration:
I am making a concerted effort to wrap my head around Rspec in order
What does aspnet_regiis.exe do exactly other than updating the document mappings to correct aspnet_isapi.dll

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.