Support Forums

Full Version: Simple Python Python Compiler
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Code:
#81ack Interface (C) Under the LGPL license v3 <http://www.gnu.org/licenses/lgpl.txt>

import sys

try:
    import py_compile
except ImportError:
    print 'ERROR: py_compile module not found...'
    sys.exit(0)
else:
    print 'Imported module py_compile...'
try:
    import compileall
except ImportError:
    print 'ERROR: comileall module not found...'
    sys.exit(0)
else:
    print 'Imported module compileall...'

ifd = raw_input('Compile all?{y|n}[n]')
if ifd == 'y' or ifd == 'Y':
    p = raw_input('Directory: ')
    if p != '':
        compileall.compile_dir(p)
        sys.exit(0)
    else:
        print 'ERROR: please specify a directory...'
        sys.exit(0)

p = raw_input('File: ')
try:
    py_compile.compile(p)
except IOError:
    print 'ERROR: file not specified or directory does not exist'
    sys.exit(0)
else:
    print p+' compiled...'
I just provided a 7 day dl link. Be happy to if people find the program slightly resourceful. : /
pycompile.pyc
Thank you for providing this. Perhaps explain its functions for people who might be unfamiliar with coding?
(06-11-2010, 07:49 PM)Eve Wrote: [ -> ]Thank you for providing this. Perhaps explain its functions for people who might be unfamiliar with coding?
To be honest, it really has no concern for those who do not know how to code. Not being rude, but it's truly designed for the convenience of compiling python source. Oui

BTW, Congrats on becoming a Moderator.
Thank you, this is useful, @ Eve: as he said this script is useless if you don't know how to code, it compiles python scripts so they run faster.
There is already a module that allows you to compile python files.
So what's the purpose of creating another one?
(08-13-2010, 03:28 PM)Road Kamelot Wrote: [ -> ]There is already a module that allows you to compile python files.
So what's the purpose of creating another one?
No crap bud. This is for ease of use; nothing more or nothing less.
I fail to see how a new module would be easier than just using the one that comes with python.
(08-13-2010, 05:34 PM)Road Kamelot Wrote: [ -> ]I fail to see how a new module would be easier than just using the one that comes with python.
Well, why don't you time each method. See which one is faster.
In Linux I can enter one line and it will compile a python file to a .pyc
I'm sure there is something like that for windows as well.
Pages: 1 2 3