tgoop.com/terminal_stuff/2812
Create:
Last Update:
Last Update:
The Unix env Lookup Trick
On some Unix systems, you can avoid writing the path to the Python interpreter in your script file by writing a special comment on the first line, like this:
#!/usr/bin/env pythonThis tells the env program to find the Python interpreter based on your system's search path settings. This can make your scripts more portable, because you don't need to hard code the path to Python in the first line of all your scripts. This means that if you move your scripts to a new machine, or if Python is moved to a new location, you only need to update the PATH environment variable, not all of your scripts.
...script goes here...
As long as env is available on all systems where you want to run your scripts, they will work no matter where Python is installed on your system. In fact, this form of env is generally recommended over even something as generic as
/usr/bin/python
, because some platforms may install Python in other locations. However, it is important to note that this assumes that env is installed in the same location on all systems. On some machines, it may be installed in /sbin
, /bin
, or another directory. If this is not the case, then your scripts will not be portable.Learning Python: Powerful Object-Oriented Programming
Book by Mark Lutz
🗞 La3tKnight
BY نوشتههای ترمینالی
Share with your friend now:
tgoop.com/terminal_stuff/2812