TGViewer
نوشته‌های ترمینالی نوشته‌های ترمینالی @terminal_stuff · 3.52K subscribers
Post #2812 1.16K

Forwarded from La3tKnight

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 python
...script goes here...

This 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.

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
More from @terminal_stuff
  1. Oct 10, 2026🚨 تلگرام دسکتاپ رو فورا آپدیت کنید (ورژن‌های قبل 7.2.9 آسیب‌پذیری بحرانی دارند) به‌دلیل E…
  2. Oct 5, 2026💡گواهی ریشه داخلی چیست و چرا نباید برای دسترسی به اینترنت بانک آن را روی دستگاه خود نصب ک…
  3. Sep 23, 2026I am done with this shit Article, Comments
  4. Sep 19, 2026اگه حوصله دارید ببینید به نظرم ایده های جالبی مطرح کرده.
  5. Sep 19, 2026اینو یادم رفته بود اینجا بذارم. یه گپ است در مورد هوش مصنوعی و اینکه چه فرصت هایی رو برای…
  6. Sep 17, 2026از زبون آمار: آیا AI کدهای خوبی می‌نویسه یا نه؟ وقتی تولید کد تقریباً مجانی و خیلی سریع ان…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →