permission

Skip Montanaro skip at pobox.com
Tue Apr 12 23:15:03 EDT 2005


    James> Is it possible to check if you have permission to access and or
    James> change a directory or file?

Yes, but it's generally much easier to try, then recover from any errors:

    try:
        f = open(somefile, "a")
    except IOError, msg:
        print "can't open", somefile, "for writing"
    else:
        f.write("hi mom!\n")

Skip



More information about the Python-list mailing list