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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:13:11+00:00 2026-05-25T20:13:11+00:00

Normally I would use inspect.getargspec, however how do I get the arguments of a

  • 0

Normally I would use inspect.getargspec, however how do I get the arguments of a method that has been bound?

Eg, how do I get the argument names for the method ‘foo’ as follows:

class Foo(object):

    @memoized
    def foo(self, arg1, arg2):
        pass

Note that Foo().foo is a memoized object, http://wiki.python.org/moin/PythonDecoratorLibrary#Memoize

This means that it is really a functools.partial instance.

How do I get the original function or alternatively, obtain the arguments somehow?

If I can’t, does this indicate a design flaw of the PythonDecoratorLibrary?

  • 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-05-25T20:13:12+00:00Added an answer on May 25, 2026 at 8:13 pm

    You could add a _wrapped attribute to the partial, which may be what you did already:

    def __get__(self, obj, objtype):
        """Support instance methods."""
        f = functools.partial(self.__call__, obj)
        f._wrapped = self.func
        return f
    

    Or you could return self.func instead of the partial if obj is None (i.e. if it’s accessed from the class instead of an instance):

    def __get__(self, obj, objtype):
        """Support instance methods."""
        if obj is None:
            return self.func
        else:
            return functools.partial(self.__call__, obj) 
    

    The partial’s func attribute is the memoized object’s __call__ method. If you call it from a Foo instance, then the first argument is set to the instance obj by the partial (see this in Foo().foo.args). Then in memoized.__call__, self.func(*args) works like a poor man’s bound method.

    For the lru_cache, Raymond Hettinger has Python 2 compatible implementations available as ActiveState Code Recipes. There’s also a version for least frequently used, in addition to least recently used.

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

Sidebar

Related Questions

Normally I would just use URL GET parameters but CodeIgniter doesn't seem to like
I would normally use Google analytics because it is free and simple to implement
Using win forms with an MVC / MVP architecture, I would normally use a
Normally if I'd like to have an Erlang process timeout I would use the
I have identified the query constructs my users normally use. Would it make sense
I normally would create a limited rights user and run the process under that
Normally I would have one junit test that shows up in my integration server
normally I would use Python/Perl for this procedure but I find myself (for political
I have a applet in a webpage that I use and I would like
I have an issue I'm trying to debug, and normally I would use Firebug's

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.