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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:57:53+00:00 2026-06-07T08:57:53+00:00

My application has a class full of functions that perform various operations. These operations

  • 0

My application has a class full of functions that perform various operations. These operations are related to 1 and only 1 dictionary key. How can I associate the dictionary key with its respective function? The goal of the tool will be for it to use the appropriate set of functions when given a set of keys.

This is how I currently work it out:

class MyClass:

    def FuncA(self):
        # Some code -----------------------------

    def FuncB(self):
        # Some code -----------------------------

myDict["Objective A"] = MyClass.FuncA()
myDict["Objective B"] = MyClass.FuncB()

Due to the nature of my program, the set of keys that will be used can change from time to time. Therefore, hard coding it as I have makes no sense. I want to be able to loop through my set of keys and run the appropriate functions. Remember, ObjectiveA is associated with FuncA. Therefore, if ever ObjectiveA was to appear in my list of keys, FuncA would need to be called in order to process some operation and populate the respective value pair.

Envisioning this:

for k in myDict.keys():
    myDict[k] = MyClass.TheAssociatedFunction()
  • 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-07T08:57:54+00:00Added an answer on June 7, 2026 at 8:57 am
    myDict["Objective A"] = MyClass.FuncA()
    

    associates the return value of MyClass.FuncA. If you want to associate the function itself:

    myDict["Objective A"] = MyClass.FuncA
    myDict["Objective B"] = MyClass.FuncB
    

    Then you can call it directly:

    myDict["Objective A"]()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Android app that has an Application class and I have another
I am developing an asp.net mvc application, which has these enity classes: public class
I've got a web application that has a page full of batch files which
I have an application which resides in ROOT. This application has a java class(in
I am developing an application which has around 8 Activities, and a class which
In my application I have a class which has properties of user-defined types like
I am working on a WPF MVVM application. It has a custom canvas class
i have an application that has an alarm system that works flawlesly and i
I have a small problem with an Xpage Application and hope that someone has
While writing yet another class full of methods that access database tables to work,

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.