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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:52:08+00:00 2026-05-21T10:52:08+00:00

I have an application consisting of a base app that brings in several modules.

  • 0

I have an application consisting of a base app that brings in several modules. The base app reads a parameter file into a configuration hash, and I want to share it across all my modules.

Currently, I am passing a ‘parent’ object down to modules, and then those modules are doing stuff like self.parent.config to obtain the configuration.

However, as there are several levels to the module hierarchy, I find myself doing things like self.parent.parent.config, which is starting to look bad.

What are some better patterns for sharing a config object across an application and it’s modules? I am thinking about having a ‘config’ module which basically creates a global config variable that can be set by the base app, then imported and accessed by other modules, but I am not sure if using globals like that is a bad practice for other reasons.

I am reasonably new to Python so be nice =)

  • 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-21T10:52:09+00:00Added an answer on May 21, 2026 at 10:52 am

    You could just:

    import config
    

    and have a global config module


    excerpts from my comments:

    You can always add special rules for odd situations by just saying oddValue if isOddSituation() else config.normalValue.

    If you want to have configuration modules be hierarchically subclassable (like my other answer describes), then you can represent a config as a class, or you can use the copy module and make a shallow copy and modify it, or you can use a “config dictionary”, e.g.:

    import config as baseConfig
    config = dict(baseConfig, overriddenValue=etc)
    

    It doesn’t really matter too much which scope you’re in.

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

Sidebar

Related Questions

I have flex application consisting of several modules which is configured using maven. I'm
I have an application consisting of different modules written in C++. One of the
I have an application consisting of about 5 executable programs that connect to a
I have a web application consisting of severals modules. All the modules are packaged
I have a vb application consisting of several winForms and code files. Is it
We have a C application for Linux consisting of few modules. Each module can
I have a DB consisting of 4 fields.My application will retrieve data from that
I have an application that uses a SQL Server database with several instances of
In most of the web application, i have seen one base class consisting common
I have a web application consisting of an aspx-file. On page load two textboxes

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.