Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple Python Python Compiler
#1
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...'
Do what thou wilt shall be the whole of the Law. Love is the law, love under will.
.::The Rights of Man::.
Reply
#2
I just provided a 7 day dl link. Be happy to if people find the program slightly resourceful. : /
pycompile.pyc
Do what thou wilt shall be the whole of the Law. Love is the law, love under will.
.::The Rights of Man::.
Reply
#3
Thank you for providing this. Perhaps explain its functions for people who might be unfamiliar with coding?
Reply
#4
(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.
Do what thou wilt shall be the whole of the Law. Love is the law, love under will.
.::The Rights of Man::.
Reply
#5
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.
[Image: izsyo6.jpg]


Reply
#6
There is already a module that allows you to compile python files.
So what's the purpose of creating another one?
Reply
#7
(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.
Do what thou wilt shall be the whole of the Law. Love is the law, love under will.
.::The Rights of Man::.
Reply
#8
I fail to see how a new module would be easier than just using the one that comes with python.
Reply
#9
(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.
Do what thou wilt shall be the whole of the Law. Love is the law, love under will.
.::The Rights of Man::.
Reply
#10
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  (★ Dяea Tutorials ★ )-==-[ DataBases in Python ]-==-(★Tutorial no.1★) Dяea 17 4,264 09-30-2019, 01:00 AM
Last Post: samsmith001
  help with simple python 2.6 task cardinalmanjune 1 873 09-30-2019, 12:59 AM
Last Post: samsmith001
  Python Help Dεlluzion 3 1,734 09-30-2019, 12:59 AM
Last Post: samsmith001
  Beginner's Python help!! proctortom 0 939 03-19-2014, 07:37 PM
Last Post: proctortom
  python help can you help me turn theses to pythons benwadee 0 895 08-13-2013, 03:43 AM
Last Post: benwadee

Forum Jump:


Users browsing this thread: 1 Guest(s)