Should Python library modules start with #!/usr/bin/env python?
Looking at first lines of *.py in /usr/share/pyshared (where Python libs are stored in Debian) reveals that there are both files that start with the hashbang line and those that do not.
Is there a reason to include or omit this line?
The reason why some files in
/usr/share/pysharedhave declared the shebang & some do not are easy to explain. Take the filesuno.pyandpyinotify.py. The former has no shebang and the latter has.uno.pyis a python module which will be imported and used in other programs/scripts. Thus it will never be executed directly from the command line.On the other hand
pyinotify.pycontains the shebang and you can see that it contains the following line at the bottom (it can made into an executable if you run achmod u+xon it):You can hardcode the python binary in the shebang, but as others have mentioned, using
/usr/bin/envwill make it more portable.