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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:18:49+00:00 2026-06-14T14:18:49+00:00

Currently my configuration options (constants / variables) are a bit fragmented, I have most

  • 0

Currently my configuration options (constants / variables) are a bit fragmented, I have most of them in config.py but some are in the myfile.py at the top.

/utilities/myfile.py
/config.py

An example of what you might find in my myfile.py is:

TEMP_DIR = '/tmp'

If I wanted to move this definition from my myfile.py into my config.py but still use it in my myfile.py, how do I go about it?

I am new to python but I assume it is something along the lines of this at the top of myfile.py

from config
  • 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-14T14:18:50+00:00Added an answer on June 14, 2026 at 2:18 pm

    variant 1

    from config import *
    

    this polutes the whole namespace in myfile.py

    variant 2

    from config import foo, bar, baz
    

    Ever value used in myfile.py have to be mentioned.

    variant 3

    import config
    ...
    x = config.foo
    

    every value need to refer to config.

    Your choice, but i prefer variant 3. To see config.py in myfile.py, you either have to edit your PYTHONPATH or use a relative import:

    from ... import config
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a problem with my jgroups configuration, causing thousands of messages getting
Currently I do the following: Create package using msbuild something.csproj /P:Configuration:Some /T:Package After that
Hey, I want to store application configuration data. Currently, I'm using INIs but they
I am currently developing an MMC snap-in but have hit a big snag -
For my app, I have a fairly complex set of configuration options that user
I have this simple script which works fine, but currently overwrites files with duplicate
Configuration : Guice 1.0, Apache Tomcat 6.0 I am currently manually injecting objects configured
When reading our configuration and resource files, our .Net system currently just does ConfigurationManager.AppSettings[keyToFind]
I've been tasked with updating a function which currently reads in a configuration file
I'm aware that similar questions on SO are numerous, but I have a caveat.

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.