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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:22:28+00:00 2026-06-07T18:22:28+00:00

I am not 100% sure this is called lazy-evaluation or not, but I am

  • 0

I am not 100% sure this is called lazy-evaluation or not, but I am hoping to do this in Python.

I have a "setup wizard" which a user will go through and in turn create some global variables which will be used as parameters in a class.

var = myClass(param1, param2) should not be evaluated until global variables param1 and param2 exist. However, I need var to exist because I am associating var0 = var.func, a function inside myClass. Later on in the application, var0 is called and func() is performed.

Updated

Here is a bit of my code:

class myClass:

    def __init__(self, param1, param2):
        self.param1 = param1
        self.param2 = param2
    #------------------------------------------------------------------------
    def myFunction(self):
        """
        Some work here using self.param1 and self.param2
        """
    def myFunction2(self):
        """
        Some work here using self.param1 and self.param2
        """
    def myFunction3(self):
        """
        Some work here using self.param1 and self.param2
        """

myInstance = myClass(PARAM1, PARAM2)

myDict = {}
myDict["key1"] = myInstance.myFunction
myDict["key2"] = myInstance.myFunction2
myDict["key3"] = myInstance.myFunction3
# and so on...

PARAM1 and PARAM2 are populated as global variables by the user through actions inside of a wxPython wizard. The problem is that myInstance cannot be evaluated at initialization because PARAM1 and PARAM2 don’t exist yet. However, the dictionary key’s are being associated to the various functions at initialization because they won’t change over time.

Ideas?

  • 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-07T18:22:29+00:00Added an answer on June 7, 2026 at 6:22 pm

    I used the @staticmethod decorator to get past this in my code, but I won’t accept it as an answer as I don’t know if this is the best answer at the moment!!

    class myClass:
        #------------------------------------------------------------------------
        @staticmethod
        def myFunction(param1, param2):
            """
            Some work here using param1 and param2
            """
        @staticmethod
        def myFunction2(param1, param2):
            """
            Some work here using param1 and param2
            """
        @staticmethod
        def myFunction3(param1, param2):
            """
            Some work here using param1 and param2
            """
    
    myDict = {}
    myDict["key1"] = myClass.myFunction
    myDict["key2"] = myClass.myFunction2
    myDict["key3"] = myClass.myFunction3
    # and so on...
    

    and after the user passes through the setup wizard and populated PARAM1 and PARAM2, I can loop through the dictionary and calculate the respective value pair using its associated function by passing PARAM1 and PARAM2 like so:

    for k in myDict.keys():
        myDict[k](PARAM1, PARAM2)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This sounds daft and easy but I'm not 100% sure here. I have this
I'm not 100% sure how I should word this question but I'll try my
I'm not 100% sure I'm doing this right, but I think I've found an
I'm not quite sure what this is called, but I've spent some time thinking
I'm not really 100% sure how to describe this, but I will try my
I know the behavior, but I am not 100% sure on why this occurs.
I'm not 100% sure what the correct terminologies are but.. I have a class
Hey, not 100% sure what this error means. % for f in * ;
I'm not 100% sure if the problem is with openTK but it is the
So I have an issue that I'm not 100% sure on how to solve.

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.