On Saturday, Apr 21st 2007 at 19:18 +0100, quoth Michael Hoffman: =>Chris Lasher wrote: =>> Should a Python module not intended to be executed have shebang/ =>> hashbang (e.g., "#!/usr/bin/env python") or not? I'm used to having a =>> shebang in every .py file but I recently heard someone argue that =>> shebangs were only appropriate for Python code intended to be =>> executable (i.e., run from the command line). => =>Personally I include it in all of them, as part of boilerplate in a =>template.
I'd recommend againt it. The shebang doesn't do you any good unless it's also in the presence of a file that has its executable bit set. For example, let's leave python out for a second: I have a shell script. And I also have lots of files which are not intended to be executed which are also shell scripts, but which are sucked in by the shell "." or "source" command (which is *somewhat* analogous to python's import). Lots of these shell "library" scripts can't execute as standalone. The same thing is possible with pything scripts. Of course, anything that has if __name__ == "__main__": in it should always have a shebang and be executable. -- Time flies like the wind. Fruit flies like a banana. Stranger things have .0. happened but none stranger than this. Does your driver's license say Organ ..0 Donor?Black holes are where God divided by zero. Listen to me! We are all- 000 individuals! What if this weren't a hypothetical question? steveo at syslang.net -- http://mail.python.org/mailman/listinfo/python-list