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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:47:17+00:00 2026-05-31T11:47:17+00:00

I have a dictionary of methods in Python that is inside of a definition.

  • 0

I have a dictionary of methods in Python that is inside of a definition. This def is called outside of the class using an object. Whenever the def is called I am returned the results of the last item in the dictionary. In this case I am returned the results of def spc_summary:.

 def setStyles(self):
    # Assign function to file
    functions = {
            'app_server.php':self.app_server(),
            'dcrm2nlyte.php':self.dcrm2nlyte(),
            'export.php':self.export(),
            'host_server.php':self.host_server(),
            'spc.php':self.spc(),
            'spc_approved.php':self.spc_approved(),
            'spc_approved_by_dc.php':self.spc_approved_by_dc(),
            'spc_by_dc.php':self.spc_by_dc(),
            'spc_complete.php':self.spc_complete(),
            'spc_summary.php':self.spc_summary()
    }

    filename = self.phpfile
    functions.get(filename)

Can someone please explain what is happening here? Let me know if more detail is required. Thanks!

Let me add some detail:
The functions.get(filename) is retreiving the last dictionary item reguardless of what filename is. I have done this => functions('spc.php') and it still returned results for `def spc_summary’. And those def’s should not have the same results.

  • 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-31T11:47:19+00:00Added an answer on May 31, 2026 at 11:47 am

    Your function dict seems to be doing the wrong thing. While defining your dict you are mapping the keys to the function result instead of the function object. If you map it to the function object the function gets called when you invoke functions.get(filename)()

    Your dict should probably be like below:

    functions = {
            'app_server.php':self.app_server,
            'dcrm2nlyte.php':self.dcrm2nlyte,
            'export.php':self.export,
            'host_server.php':self.host_server,
            'spc.php':self.spc,
            'spc_approved.php':self.spc_approved,
            'spc_approved_by_dc.php':self.spc_approved_by_dc,
            'spc_by_dc.php':self.spc_by_dc,
            'spc_complete.php':self.spc_complete,
            'spc_summary.php':self.spc_summary
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an interface called Dictionary which has a method insert() . This interface
I have a Python set that contains objects with __hash__ and __eq__ methods in
I have a method in c++ that gets called from python and needs to
I have a Dictionary<string, someobject> . EDIT: It was pointed out to me, that
I have a dictionary that I normally access with a key, so I need
I have a Dictionary that when I add multiple values to it, the items
I have resource dictionary files (MenuTemplate.xaml, ButtonTemplate.xaml, etc) that I want to use in
I have a dictionary in Python where the keys are pathnames. For example: dict[/A]
So I have the following situation. I have a configuration class config.py that holds
In Python, you can assign an arbitrary attribute from outside the defining 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.