Posts: 4,646
Threads: 1,493
Joined: Sep 2016
there appears to be many ways to test if i have a reference to a directory (as opposed to something else like a file or a path that does not exist). which method of testing should i
not use? is there a reason why
not?
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,646
Threads: 1,493
Joined: Sep 2016
Mar-21-2017, 04:17 AM
(This post was last modified: Mar-21-2017, 04:59 AM by Skaperen.)
sorry, my head slipped into that old box again. gotta be thinking more pythonic.
rewriting this and rethinking it.
what the script needs to do is make sure a directory is there, given a path in a string. i just recoded it to make the directory. that will fail if something was already there. it will usually be a directory, previously created. that is ok if so. it might be something else like a regular file. that is bad and we must not go on. this script does nothing with the directory, it invoke another program that will use the directory or fail badly if there is not a directory there. so my thought is to test if it is a directory by using it in some benign way like cd into it and cd back out. how pythonic is this? the path is obtained from a command environment passed along to the next program. this script is being made to run before that next program to modify and improve the startup conditions, such as making sure the logging directory exists. if it fails to cd into that directory it will delete important files from the current directory, so i want to be as sure as possible that it will succeed.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,646
Threads: 1,493
Joined: Sep 2016
ok, i will mkdir then os.path.isdir(). if os.path.isdir() indicates not a directory, the i will abort. simple enough.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.