seperate directory for .pyc files

Jeff Schwab jeff at schwabcenter.com
Fri Feb 15 21:09:38 EST 2008


Amit Gupta wrote:
> Python'ites
> 
> Is there an environment variable or some settings, that python can use
> to know the directory name for dumping .pyc files.
> 
> Not a hard-requirement, I just don't like pyc files alongwith py files
> in my work area.

Does this help?

# ls.py
import subprocess
import sys

pipe = subprocess.Popen(
         ["ls"] + sys.argv[1:], stdout=subprocess.PIPE)

paths = pipe.communicate()[0].rstrip().split('\n')

for path in paths:
     if not path.endswith(".pyc"):
         print path



More information about the Python-list mailing list