.pyc write location

John Kominek jkominek at cs.cmu.edu
Wed Apr 23 22:46:50 CEST 2003


I have a question about the location of compiled objects. By default, 
when you compile a source file to a pyc (or pyo) file, the output file 
is in the same directory as your source. I've always found this behavior 
untidy. Maybe it's just me, but I like to build object files in a 
directory separate from my source code.

There compile() funtion in py_compile allows for a non-standard location 
to be specified,

    def compile(file, cfile=None, dfile=None, doraise=False):
        if cfile is None:
            cfile = file + (__debug__ and 'c' or 'o')
        fc = open(cfile, 'wb')

 But can this be controlled from the command line when invoking the 
interpreter? If there's previous discussion on this topic, or a FAQ 
entry, I'd appreciate any pointers.


More information about the Python-list mailing list