I think I found it online. This fragment
C:\> mapit 870 Valencia St, San Francisco, CA 94110
(namely C:\>
) and other details indicate the author uses Windows. In Windows there are ways to run files of certain extensions by typing their names without extensions. The author most likely has enabled the feature for .py
. Compare this: Making Python scripts run on Windows without specifying .py
extension.
In Unix/Linux .py
in script.py
is just a part of the name. There is no concept of extension (other than the concept in user's mind maybe).
So just name the script script
instead of script.py
. If you want to be able to run the same script regardless if you type script.py
or script
, then place the script under one name and make a symlink from the other name to the actual script.
Note (at least in Linux) there is script(1)
utility. Depending on your PATH
a command script
will run the script or the utility (if installed).
Another approach is to make your shell try to run foo.py
if foo
resulted in command not found
(for any foo
). See this general question:
and these two answers as examples (note they are for Bash):
In Zsh the function is named command_not_found_handler
. Build your solution by porting one of the examples to Zsh.