I want to write a script which checks and opens a settings-file called “.mysettings” if it exists in the HOME-directory. If the file is not present in the HOME-directory it should try to open one in the current directory if it exists there.
Is there a idiom or a one-liner in python to program something like that?
The best way I can think of right now is to try to open the first file with a try-catch block like explained in this question and then trying the second file.
This is the python way to do it. No one liner, but clear, and easy to read.
Of course, you could always do something like this as well: