How about some syntactic sugar for " __name__ == '__main__' "?

Ethan Furman ethan at stoneleaf.us
Tue Dec 2 05:17:11 EST 2014


On 12/01/2014 05:15 PM, Chris Angelico wrote:
> On Tue, Dec 2, 2014 at 11:45 AM, Ethan Furman wrote:
>>
>> Put the above somewhere in your path (e.g. /usr/local/bin), make it executable, and then instead of shebanging your
>> scripts with `/usr/local/bin/python` you can use `/usr/local/bin/py_main`, which will load and execute the script,
>> calling script.main as its last act.
> 
> Be aware that this trick (shebanging to a script rather than a binary)
> isn't specified by the POSIX standard. It works on Linux, but I don't
> know about other systems. 

Ah, thanks for that!

--
~Ethan~

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20141202/4817b904/attachment.sig>


More information about the Python-list mailing list