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 8291883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:16:55+00:00 2026-06-08T13:16:55+00:00

#!/usr/bin/python from functools import wraps def logged(func): @wraps(func) def with_logging(*args, **kwargs): print func.__name__ +

  • 0
#!/usr/bin/python

from functools import wraps
def logged(func):
    @wraps(func)
    def with_logging(*args, **kwargs):
        print func.__name__ + " was called"
        return func(*args, **kwargs)
    return with_logging

@logged
def f(x):
   """does some math"""
   return x + x * x

I want to know if wraps has the undecorated reference to the function f? I don’t see it when I tried dir(f)


Modified version

#!/usr/bin/python

from functools import wraps
def logged(func):
    @wraps(func)
    def with_logging(*args, **kwargs):
        print func.__name__ + " was called"
        return func(*args, **kwargs)
    with_logging.undecorated = func
    return with_logging

@logged
def f(x):
   """does some math"""
   return x + x * x

f.undecorated

No attribute? I was merely following what I used to do with decorator…

  • 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. Editorial Team
    Editorial Team
    2026-06-08T13:16:56+00:00Added an answer on June 8, 2026 at 1:16 pm

    There is a reference to the original f in there, but it’s messy to get to.

    >>> f
    <function f at 0x023F6DF0>
    >>> f.func_closure[0].cell_contents
    <function f at 0x023F6E30>
    

    The first is the wrapped f, the second is the original f, notice the hex addresses are different.

    If you need access to the original f, I suggest you wrap it differently:

    def f(x):
       """does some math"""
       return x + x * x
    original_f = f
    f = logged(f)
    

    Now you have f and original_f, both usable.

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

Sidebar

Related Questions

#!/usr/bin/python from string import Template s = Template('$x, go home $x') s.substitute(x='lee') print s
What is this error message ? My code #!/usr/bin/python from xml.dom.minidom import Document def
I tried this: #!/usr/bin/python from wsgiref.simple_server import make_server from cgi import parse_qs, escape import
my views.py file code: #!/usr/bin/python from django.template import loader, RequestContext from django.http import HttpResponse
This is my piece of code: #!/usr/bin/python from xml.etree.ElementTree import ElementTree from array import
#!/usr/bin/python # -*- coding: iso-8859-1 -*- import Tkinter import twitter class simpleapp_tk(Tkinter.Tk): def __init__(self,parent):
#!/usr/bin/python # -*- coding: iso-8859-1 -*- import Tkinter class simpleapp_tk(Tkinter.Tk): def __init__(self,parent): Tkinter.Tk.__init__(self,parent) self.parent=parent
I typically write my scripts with a structure like s #!/usr/bin/python import stuff def
I can't figure out why this program is failing. #!/usr/bin/env python from __future__ import
Consider the code below: #!/usr/bin/env python from PyQt4 import QtCore, QtGui import os,sys class

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.