"py" command for Linux and Mac?

Mats Wichmann mats at wichmann.us
Thu May 12 13:52:33 EDT 2022


On 5/12/22 10:25, Dan Stromberg wrote:
> Hi folks.
> 
> I heard there's a Windows-like "py" command for Linux (and Mac?).
> 
> I'm finally getting to porting a particular project's Python 2.7 code to
> 3.x, and one of the first steps will probably be changing a lot of "python2
> script.py" to use #!/usr/bin/env python2 and chmod +x.  Then we can update
> the scripts one at a time to use #!/usr/bin/env python3.
> 
> However, would this be Linux-and-Mac-only?  I'm not at all sure this code
> will ever move to Windows, but in case it does, would a "py" command work
> on all 3 if I use #!/usr/bin/env py?

The py command (python lanucher) respects shebang lines.

https://docs.python.org/3/using/windows.html#python-launcher-for-windows




More information about the Python-list mailing list