[EMAIL PROTECTED] wrote on 09/18/2008 06:12:30 PM:
> i want to check if a dir does not exist. how do i change this statement
> to evaluate is NOT existing? ==False or ! operator. Also, is sys.exit
> appropriate to use to quit out of the program?
>
> if(os.access(target_dir, os.F_OK)):
> print "File does not exist!"
> sys.exit
>
os.access(target_dir, os.F_OK) is going to return False if the directory
does not exist so take your pick how you want to check it.
if not os.access(target_dir, os.F_OK):
or
if os.access(target_dir, os.F_OK)==False:
or
if os.access(target_dir, os.F_OK)!=True:
I like the first one, others like the second.
the below doesn't work in python
>>> if !(os.access(target_dir, os.F_OK)):
SyntaxError: invalid syntax
sys.exit is fine as long as you call it.
sys.exit()
you left off the () in your sample code, and I wasn't sure if that was a
typo or not.
Python will not raise an error.
Chris
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor