executing .pyc file

Kevin Cazabon kevin at cazabon.com
Mon Dec 3 12:27:31 EST 2001


The trick I've always used on Windows is to distribute a separate .py
file that simply imported and executed the proper function in the .pyc
file.  You should be able to directly execute a .py file this way.

ex:

#!/user/bin/python
# .py file that can be freely distributed
if __name__ == "__main__":
    import myPycFile
    main = myPycFile.main()


I have no problem with that being in "readable" text, and it starts
the .pyc properly when called directly.

Kevin.

################

Tripp Scott <tripp81 at yahoo.com> wrote in message news:<mailman.1007377625.28719.python-list at python.org>...
> On 03/12/2001 16:34, Oleg Broytmann wrote:
> >On Mon, Dec 03, 2001 at 01:53:41PM +0700, Tripp Scott wrote:
> > > has someone written a trick so i can directly execute .pyc in
> > > unix?
> >
> >    http://www.lyra.org/greg/python/#dev
> 
> cool. but the .pyc is now not valid for python (can't be 
> imported as usual). i think i'll settle with a script wrapping 
> the original .py, that way i can also get a shorter name.
> 
> thanks,
> t



More information about the Python-list mailing list