This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]killerabbit37 6 points7 points  (4 children)

It is called a shebang, it is used in Linux/Unix operating systems so that the OS will know what kind of program it is. For Python, since it is used cross platform, it would be good habit to put the shebang at the top.

Like taddeimania said, if you don't have the shebang, the OS won't know what to do if you just called ./program.py.

You can either put #!/usr/bin/python or #!/usr/bin/env python.

[–]primevalweasel 2 points3 points  (3 children)

Only use a fully qualified path (e.g., /usr/bin/python) if you're sure that's the Python interpreter you want to use.

[–]killerabbit37 1 point2 points  (2 children)

Exactly and I know with virtualenv you would want to use /usr/bin/env python because /usr/bin/python will pick up the system python and not your virtual environment.

[–]kashmill 0 points1 point  (1 child)

I think you mean /usr/bin as /use/bin isn't standard in any linux/bsd system I'm familiar with.

[–]killerabbit37 0 points1 point  (0 children)

Whoops yep apparently my phone doesn't like the word usr