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. Anoop

    Larry Bates Guest

    Note: You really don't have to post the same question
    3 times (2 in response to yourself).

    import os

    if os.path.exists(pathname):
    <do something>

    To see if a file is writeable:

    import stat

    def iswriteable(path):
    mode=os.stat(path)[stat.ST_mode]
    return bool(stat.S_IMODE(mode) & stat.S_IWRITE)


    Larry Bates

    Anoop wrote:
    > 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
    >
    Larry Bates, Jul 20, 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:
    379
    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:
    274
    Lawrence D'Oliveiro
    Jul 21, 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