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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:41:48+00:00 2026-06-17T21:41:48+00:00

Possible Duplicate: How to dynamically load a Python class I’m currently using a ‘while’

  • 0

Possible Duplicate:
How to dynamically load a Python class

I’m currently using a ‘while’ loop to automate the process of updating games stored in a database. The ‘while’ loop iterates until the number of games has been reached. Each iteration returns the row containing all game data (version, update link, etc).

Now I’ve created scripts for each game in a sub-directory called “Scripts”. Like this

MainScript.py
  --> Scripts
       --> Game1.py
       --> Game2.py
       --> Game3.py

Now MainScript calls all the game scripts one by one, after connecting to the database and getting the game names.

But the problem is the game name stored in the database is a string and the functions in each of the Game1.py, Game2.py, Game3.py are identical to the game name.

This means that when I try call a function for the game, lets say “Minecraft”. It would have to look like this.

Scripts.Minecraft.Minecraft(version, size, download)

Now trying to do this dynamically is my question. Because it’s in a while loop, the name part changes for each iteration. How do I do this dynamically?

Scripts.<GameName>.<GameName>(version, size, download)

It always takes the variable literally and says it cannot use it. How do I use variables when calling the function?

  • 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-17T21:41:50+00:00Added an answer on June 17, 2026 at 9:41 pm

    Try using getattr. E.g. given the the game name is in the gamename variable:

    getattr(getattr(Scripts, gamename), gamename)(version, size, download)
    

    should work.

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

Sidebar

Related Questions

Possible Duplicate: Issue regarding dynamically loading Images in loop using Java Swing Can any
Possible Duplicate: How to add dynamically a combobox using jQuery Look, I've this working
Possible Duplicate: Dynamically Growing an Array in C++ I want to create a loop
Possible Duplicate: Getting an issue while checking the dynamically generated checkbox through list view
Possible Duplicate: Getting an issue while checking the dynamically generated checkbox through list view
Possible Duplicate: dynamically added class can’t be called jquery does not select jquery added
Possible Duplicate: Remove Datepicker Function dynamically In my web application i am using the
Possible Duplicate: How to get function parameter names/values dynamically from javascript I'm currently working
Possible Duplicate: Dynamically loading a class in Java hi i am trying to create
Possible Duplicate: Dynamically Including jQuery using JavaScript if it's not already present I am

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.