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

  • Home
  • SEARCH
  • 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

Ask A Question

Stats

  • Questions 171k
  • Answers 171k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer SELECT * FROM myRecords t1 WHERE c = (SELECT max(c)… May 12, 2026 at 2:13 pm
  • Editorial Team
    Editorial Team added an answer We use SOAPUI to do the functional testing initially. However,… May 12, 2026 at 2:13 pm
  • Editorial Team
    Editorial Team added an answer You might be able to get the actual physical size… May 12, 2026 at 2:13 pm

Related Questions

In this blog article they use the construct: @measured def some_func(): #... # Presumably
How are you instrumenting your UI's? In the past I've read that people have
This came up in a conversation I was having online, and it occured to
I'm a big fan of Yahoo's recommendations for speeding up websites. One of the
I'm currently trying to add an MSChart to a partial view in ASP.NET MVC

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.