python - Should Shebang lines be used in all the programs that would run through Terminal? -


my book states that:

the first line of python programs should shebang line, tells computer want python execute program. shebang line osx #! /usr/bin/env python3.

but program works fine without shebang line in terminal. should use in future? there fullstop(.) @ end of shebang line in osx or not?

there should not full stop @ end of line.

whether add shebang or not depends on how want run it. if invoke interpreter explicitly optional, i.e.

$ python3 script.py 

does not require shebang, nor require executable permission on file. can add shebang, , code still run, in case might serve documentation.

however, if want execute this:

$ ./script.py 

or

$ /path/to/script/script.py 

then need add shebang and set executable permission on file (see chmod).


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -