Created
November 16, 2023 07:54
-
-
Save shravanasati/e92a88ce5f7ae671db0904e009eaf32e to your computer and use it in GitHub Desktop.
which command for windows, place it on PATH and include '.py' in PATHEXT
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
import shutil, sys | |
try: | |
result = shutil.which(sys.argv[1]) | |
print(result if result else f"unable to find '{sys.argv[1]}'") | |
except IndexError: | |
print("not enough arguments", file=sys.stderr) | |
except Exception as e: | |
print("an unknown error occured:", e, file=sys.stderr) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment