Alex Rivera | Logout

What does the symbol "#!" mean in Python?

Asked 2011-06-09T06:23:52.743
11

What does this line of code mean? Without it, my python3 http server can't understand and let the browser download an empty .py file (depend on the link to the .py file)

#! /usr/local/bin/python3
Edit
Report

2 Answers

18

It's not a Python thing, it a hashbang (or shebang) line which indicates which interpreter should process the file.

The rules vary but, in its simplest form, a file with the name xyz (containing that as the first line), when run from the command line with xyz, will run it using that interpreter, similar to:

/usr/local/bin/python3 xyz
answered 2011-06-09T06:25:17.983
8

This is not a python specific notion, see http://en.wikipedia.org/wiki/Shebang_(Unix)

answered 2011-06-09T06:25:26.280

Your Answer