#1
  1. Caress me down
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2005
    Location
    Pennsylvania
    Posts
    289
    Rep Power
    511

    whats the purpose of...


    i see this on top of alot of programs
    Code:
    #!/usr/bin/env python
    just wanted to know why people put it up there and what it means.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    461
    Rep Power
    24
    well on linux or other *nix bases systems. There is a shell system usually something like bash or anouther shell scripting lang is used. but the #! simple in those langs is special, it tells the shell system where to send the file or who to have execure it. the #! simple is called a shebang. On windows this is ignored since it is thought to be commented out. And if you expliceltly execute a file even on linux with the shebang it will ignore that line since it thinks it is commented out.

    just a nice simple way to prefere who runs the file.
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2005
    Posts
    174
    Rep Power
    11
    it's just a quickie way to always evaluate your script to be run by the python interpreter no matter where it is on your computer.

    Python could be installed in rather obscure locations due to maybe it being installed to your home directory, or some odd location. So this acts like a path statement in windows, env goes finds python for you. What you're doing is running the env program from /usr/bin to go find python, and therefore never making a mistake so that your code always runs.

    hope that helps
    sf2k

IMN logo majestic logo threadwatch logo seochat tools logo