Checking File permissions

Discussion in 'Python' started by Anoop, Jul 20, 2006.

  1. Anoop

    Anoop Guest

    Hi All

    Please tell me how to check the existence of a file and the read
    permission to the file using python script

    Thanks for ur inputs

    Anoop
    Anoop, Jul 20, 2006
    #1
    1. Advertising

  2. In message <>, Anoop
    wrote:

    > Please tell me how to check the existence of a file and the read
    > permission to the file using python script


    Without knowing what your precise needs are, the best way is to open the
    file and try to read from it. If that succeeds, then you've got read
    access.

    Checking permissions as a separate step from opening the file exposes your
    code to a race condition where the permissions may be OK during the initial
    check, but then change to deny access before the subsequent open.
    Lawrence D'Oliveiro, Jul 21, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Scott Allen
    Replies:
    0
    Views:
    432
    Scott Allen
    Jul 13, 2004
  2. blue

    Checking File Permissions

    blue, Jul 15, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    378
    Ken Cox [Microsoft MVP]
    Jul 15, 2004
  3. Anoop

    Checking File permissions

    Anoop, Jul 20, 2006, in forum: Python
    Replies:
    2
    Views:
    331
    Tal Einat
    Jul 21, 2006
  4. Anoop

    Checking File permissions

    Anoop, Jul 20, 2006, in forum: Python
    Replies:
    1
    Views:
    282
    Larry Bates
    Jul 20, 2006
  5. David K. Wall

    checking effective file permissions

    David K. Wall, Aug 9, 2004, in forum: Perl Misc
    Replies:
    3
    Views:
    107
    Glenn Jackman
    Aug 10, 2004
Loading...

Share This Page