Last active
July 18, 2018 20:54
-
-
Save dhoss/1992a15366642adb75e6d459e665f185 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I've tried both of these: | |
try: | |
for part in parts: | |
dirs = [dir for dir in os.listdir(path_to_check) if not isfile(os.path.join(path_to_check, dir))] | |
if "thing" in dirs: | |
return path_to_check | |
del path_parts[-1] | |
else: | |
raise ValueError("thing not found") | |
except ValueError as e: | |
print(e.value()) | |
############################# | |
for part in parts: | |
dirs = [dir for dir in os.listdir(path_to_check) if not isfile(os.path.join(path_to_check, dir))] | |
if "thing" in dirs: | |
return path_to_check | |
del path_parts[-1] | |
else: | |
raise ValueError("thing not found") | |
# test | |
with self.assertRaises(ValueError): | |
self.stupid_function() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment