Skip to content

Instantly share code, notes, and snippets.

@shravanasati
Created November 16, 2023 07:54
Show Gist options
  • Save shravanasati/e92a88ce5f7ae671db0904e009eaf32e to your computer and use it in GitHub Desktop.
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
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