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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:56:37+00:00 2026-05-23T00:56:37+00:00

In a program, and obviously being influenced by the way Java does things, I

  • 0

In a program, and obviously being influenced by the way Java does things, I want to read a static file (a log configuration file, actually) from a directory within the interpreter’s PYTHONPATH. I know I could do something like:

import foo
a = foo.__path__
conf = open(a[0] + "/logging.conf")

but I don’t know if this is the “Pythonic” way of doing things. How could I distribute the logging configuration file in a way that my application does not need to be externally configured to read it?

  • 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-23T00:56:38+00:00Added an answer on May 23, 2026 at 12:56 am

    In general, that’s fine, though I’m not sure you want a[0] above (that will just give you the first character of the path), and you should use os.path.join instead of just appending / to be cross-platform compatible. You might consider making the path canonical, i.e. os.path.abspath(os.path.dirname(foo.__path__)). Note that it won’t work if __path__ is in a zip file or other import trickery is in use, but I wouldn’t worry about that (it’s not normal to do so for the main program in Python, unlike Java).

    If you do want to support zipped files, there’s pkg_resources, but that’s somewhat deprecated at this point (there’s no corresponding API I could see in the new packaging module).

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

Sidebar

Related Questions

What program can I use to decompile a class file? Will I actually get
I built a quick program that needed to loop through an enormous log file
My program is a file validation utility. I have to read in a format
My program needs to read chunks from a huge binary file with random access.
I'm making a small launcher program for my Java program, the idea being that
Strange program hang, what does this mean in debug? After attaching windbg I found
My program has to read files that use various encodings. They may be ANSI,
I'm writing a program and I want the user to be able to specify
Somewhat inexperienced programmer here trying to write a program to log into my courses
Program followed by output. Someone please explain to me why 10,000,000 milliseconds from Jan

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.