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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:07:10+00:00 2026-06-05T19:07:10+00:00

I have this code: class SomeClass: @classmethod def func1(cls,arg1): #—Do Something— @classmethod def func2(cls,arg1):

  • 0

I have this code:

class SomeClass:
    @classmethod
    def func1(cls,arg1):
        #---Do Something---
    @classmethod
    def func2(cls,arg1):
        #---Do Something---

    # A 'function map' that has function name as its keys and the above function
    # objects as values
    func_map={'func1':func1,'func2':func2}

    @classmethod
    def func3(cls,arg1):
        # following is a dict(created by reading a config file) that
        # contains func names as keys and boolean as values that tells
        # the program whether or not to run that function
        global funcList
        for func in funcList:
            if funcList[func]==True:
                cls.func_map[func](arg1)        #TROUBLING PART!!!

    if _name__='main'
        SomeClass.func3('Argumentus-Primus')

When I run this I keep getting the error:

Exception TypeError: "'classmethod' object is not callable"

I am unable to figure out what is wrong with this and would appreciate your help.

  • 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-05T19:07:11+00:00Added an answer on June 5, 2026 at 7:07 pm

    You can’t create references to classmethods until the class has been defined. You’ll have to move it out of the class definition. However using a global function map to decide what gets run is really awkward. If you described what you are trying to do with this, we could probably suggest a better solution.

    class SomeClass(object):
        @classmethod
        def func1(cls, arg1):
            print("Called func1({})".format(arg1))
    
        @classmethod
        def func2(cls, arg1):
            print("Call func2({})".format(arg1))
    
        @classmethod
        def func3(cls, arg1):
            for fnName,do in funcList.iteritems():
                if do:
                    try:
                        cls.func_map[fnName](arg1)
                    except KeyError:
                        print("Don't know function '{}'".format(fnName))
    
    # can't create function map until class has been created
    SomeClass.func_map = {
        'func1': SomeClass.func1,
        'func2': SomeClass.func2
    }
    
    if __name__=='__main__':
        funcList = {'func1':True, 'func2':False}
        SomeClass.func3('Argumentus-Primus')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have this code: jQuery('div[class=someClass] :input:not(:button)').each(function() { if (input type is drop-down) {
I have this code: class DocumentIdentifier attr_reader :folder, :name def initialize( folder, name )
I have this code: <div class=changingClass></div> <div class=someClass></div> <div class=changingClass></div> For divs that have
Have a class definition that looks something like this class someClass(models.Model): field1 = models.ForeignKey('other_app.field4')
I have a this code public class SomeClass<T>: IEnumerable<T> { public List<SomeClass<T>> MyList =
Suppose I have this code (pseudocode) class SomeClass { class Person { public static
I currently have a class something like this [DataContractAttribute] public class someClass { public
I have the following code class SomeClass def initialize(opts) if opts[:should_load] load else setup(opts[:path])
I had, and have since corrected, something like the following code: class SomeClass {
Say I have some code like this which is called on $(document).ready() $(.someClass).click(function(){ //do

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.