Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #81812
| Date | 2014-12-03 07:47 +1100 |
|---|---|
| From | Cameron Simpson <cs@zip.com.au> |
| Subject | Re: How about some syntactic sugar for " __name__ == '__main__' "? |
| References | <547D91A7.4090909@stoneleaf.us> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.16501.1417554915.18130.python-list@python.org> (permalink) |
On 02Dec2014 02:17, Ethan Furman <ethan@stoneleaf.us> wrote:
>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!
I'm pretty sure I've used systems where you could not shebang to a script.
Solaris IIRC. Several years ago, might not be an issue on modern releases.
Cheers,
Cameron Simpson <cs@zip.com.au>
For reading rec.moto, I use one of those carbon-fiber Logitech mice w/a
little 'No Fear' sticker on it. - Mike Hardcore DoD#5010 <moike@netcom.com>
Apologies to Primus
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: How about some syntactic sugar for " __name__ == '__main__' "? Cameron Simpson <cs@zip.com.au> - 2014-12-03 07:47 +1100
csiph-web