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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:16:37+00:00 2026-05-17T19:16:37+00:00

I wrote a tool that looks in several places for an INI config file:

  • 0

I wrote a tool that looks in several places for an INI config file: in /usr/share, /usr/local/share, ~/.local/share, and in the current directory.

c = ConfigParser.RawConfigParser()
filenames = ['/usr/share/myconfig.conf',
             '/usr/local/share/myconfig.conf',
             os.path.expanduser('~/.local/share/myconfig.conf'),
             os.path.expanduser('./myconfig.conf')]
parsed_names = c.read(filenames)
for name in parsed_names:
    print 'using configuration file: ' + name

I have started using virtualenv and now my setup.py script installs myconfig.conf into /path/to/virtual/env/share/. How can I add this path to the list of paths searched by ConfigParser when the path to the virtualenv will be different each time? Also, if I installed to a virtualenv, should I still search the system /usr/share and /usr/local/share directories?

  • 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-17T19:16:37+00:00Added an answer on May 17, 2026 at 7:16 pm

    You should be able to get the venv share path with

    os.path.join(sys.prefix, 'share', 'myconfig.conf')
    

    Including /usr/share or /usr/local/share would depend on your application and if multiple installations by different users would be more likely to benefit or be harmed by global machine settings. Using the above code would include '/usr/share/myconfig.conf' when using the system python so it is probably safer to not include it explicitly.

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

Sidebar

Related Questions

I wrote a simple console tool that reads a file and then writes something
I wrote a tool that queries/updates a database using Linq to SQL. The entity
I have a program that creates an object for each file in a directory
I have an XML file that looks like this: <?xml version=1.0? encoding=UTF-8 standalone=no?> <dir
I would like to write a command line tool that passes some formatted text
I need to locate a command line tool that would allow me to write
I am attempting to write a time management tool with wxPython that is ideally
I wrote simple load testing tool for testing performance of Java modules. One problem
I'm trying to write a shell script that will make several targets into several
I have a bunch of diagrams created using a Java diagramming tool that I

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.