Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #64138
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!ecngs!feeder2.ecngs.de!novso.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'importing': 0.05; 'mrab': 0.05; '__name__': 0.09; 'imported': 0.09; 'line:': 0.09; 'main()': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:into': 0.09; 'subject:script': 0.09; 'python': 0.11; 'def': 0.12; 'jan': 0.12; "'__main__':": 0.16; 'main():': 0.16; 'merely': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'import': 0.22; 'header:User-Agent:1': 0.23; 'subject: .': 0.24; 'script': 0.25; 'compiled': 0.26; 'gets': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'run': 0.32; 'executing': 0.36; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'received:173': 0.61; 'between': 0.67; 'it!': 0.67; 'sam': 0.68; 'compiling': 0.84; 'received:fios.verizon.net': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Terry Reedy <tjreedy@udel.edu> |
| Subject | Re: Compiling main script into .pyc |
| Date | Thu, 16 Jan 2014 23:45:41 -0500 |
| References | <61a24c80-12fd-4c7a-89ed-41e997b66545@googlegroups.com> <52D89BC2.4000602@gmail.com> <52D8A143.4010206@mrabarnett.plus.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | pool-173-75-254-207.phlapa.fios.verizon.net |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 |
| In-Reply-To | <52D8A143.4010206@mrabarnett.plus.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5624.1389933964.18130.python-list@python.org> (permalink) |
| Lines | 26 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1389933964 news.xs4all.nl 2833 [2001:888:2000:d::a6]:45573 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:64138 |
Show key headers only | View raw
On 1/16/2014 10:19 PM, MRAB wrote: > On 2014-01-17 02:56, bob gailer wrote: >> On 1/16/2014 8:01 PM, Sam wrote: >>> One thing I observe about python byte-code compiling is that the main >>> script does not gets compiled into .pyc. Only imported modules are >>> compiled into .pyc. >>> >>> May I know how can I compile the main script into .pyc? >> Duh? Just import it! >> > What if you want to just compile it? Importing will run it! Write the main script as def main(): ... if __name__ == '__main__': main() The difference between merely compiling 'def main' and executing it is trivial. Or don't bother compiling and write main.py as one line: from realmain import start; start() -- Terry Jan Reedy
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Compiling main script into .pyc Sam <lightaiyee@gmail.com> - 2014-01-16 17:01 -0800
Re: Compiling main script into .pyc bob gailer <bgailer@gmail.com> - 2014-01-16 21:56 -0500
Re: Compiling main script into .pyc Ned Batchelder <ned@nedbatchelder.com> - 2014-01-16 22:07 -0500
Re: Compiling main script into .pyc MRAB <python@mrabarnett.plus.com> - 2014-01-17 03:19 +0000
Re: Compiling main script into .pyc Dave Angel <davea@davea.name> - 2014-01-16 23:43 -0500
Re: Compiling main script into .pyc Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-17 08:40 +0000
Re: Compiling main script into .pyc Grant Edwards <invalid@invalid.invalid> - 2014-01-17 20:12 +0000
Re: Compiling main script into .pyc Terry Reedy <tjreedy@udel.edu> - 2014-01-16 23:45 -0500
Re: Compiling main script into .pyc Alister <alister.ware@ntlworld.com> - 2014-01-17 17:04 +0000
csiph-web