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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:36:03+00:00 2026-06-11T00:36:03+00:00

Disclaimer: i have searched genericly (Google) and here for some information on this topic,

  • 0

Disclaimer: i have searched genericly (Google) and here for some information on this topic, but most of the answers are either very old, or don’t seem to quite make sense to me, so I appologize in advance if this seems simple or uninformed.

Problem: My app accepts command line input which may be either a path or a file and I need to determine several things about it.

  1. Is it a path or file,
  2. Is it relative or absolute
  3. Is it readable and / or writable (need read and write test results)(ignoring the possibility of a race situation)

One caveat, while a

    try:
        file=open(filename,'w')
    except OSError as e:
        {miscellaneous error handling code here}

would obviously tell me if the parameter (filename in above example) existed/ was writable etc. I do not understand enough about exception codes to know how to interpret the result of exception. It also wouldn’t provide the relative/absolute information.

Assuming that there is no one method to do this then I would need to know three things:

  1. How to determine relative / absolute
  2. Is it pointing to a file or a directory
  3. can the EUID of the program read the location, and same for write.

I am seeking to learn from the information I gather here, and I am new to python and have bit off a significant project. I have mastered all of it except this part. Any help would be appreciated. (Pointers to good help sites welcome!)(except docs.python.org that ones bookmarked already 😉 )

  • 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-11T00:36:04+00:00Added an answer on June 11, 2026 at 12:36 am

    Here are your answers. The documentations specifies that the following works for both windows and linux.

    1. How to determine relative / absolute
      os.path.isabs returns True if the path is absolute, False if not.

    2. Is it pointing to a file or a directory
      Similarly Use os.path.isdir to find out if the path is directory or not.
      YOu can use os.path.isfile(path) to find out if the path is file or not.

    3. can the EUID of the program read the location, and same for write.
      You can use os.access(path, mode) to know if operations requiring permissions specified by mode are possible on file specified by path or not.
      P.S. This will not work for files being accessed over the network. You can use os.stat This is the right way to get all the information. However it is a more costly call and hence, you should try and get all the info in one call . To interpret the results, you can use the stat module

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

Sidebar

Related Questions

I have searched but have not found my answer. Disclaimer: I am brand new
(Disclaimer: I realize this is a massive wall of text, but I have done
Disclaimer : I have seen the exact questions, but have not seen any answers
Disclaimer This is not strictly a programming question, but most programmers soon or later
Disclaimer I have searched for duplicates, but I can't seem to find them. I
Disclaimer: I have looked through this question and this question but they both got
Disclaimer: I have attempted to contact the developer about this plugin, but silence reigns.
Disclaimer: I have no prior experience in MVVM/MVC/MVP/MVWhatever, this is my very first try
Disclaimer: I have not used RoR, and I have not generated tests. But, I
I have a WPF sorting/binding issue. (Disclaimer: I am very new to WPF and

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.