Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; 'svn': 0.04; 'sys': 0.05; 'git': 0.07; 'subject:files': 0.09; 'cc:addr:python- list': 0.15; '*nix': 0.16; 'filenames': 0.16; 'skip:# 30': 0.16; 'wrote:': 0.18; 'cc:no real name:2**0': 0.21; 'header:In-Reply- To:1': 0.23; 'cc:2**0': 0.25; 'windows': 0.26; 'url:mailman': 0.27; 'import': 0.28; 'pass': 0.28; 'cc:addr:python.org': 0.29; 'message-id:@mail.gmail.com': 0.29; 'print': 0.29; 'os,': 0.30; 'nov': 0.31; 'pm,': 0.31; 'received:209.85.161.46': 0.31; 'received:mail-fx0-f46.google.com': 0.31; 'thu,': 0.32; 'url:listinfo': 0.32; 'received:209.85.161': 0.35; 'url:python': 0.35; 'but': 0.37; 'received:google.com': 0.38; 'skip:o 20': 0.38; 'received:209.85': 0.38; 'url:org': 0.38; "it's": 0.39; 'subject:: ': 0.39; 'change': 0.39; 'received:209': 0.40; '2011': 0.62; 'andrea': 0.84; 'nice,': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=mJxjdTbhJO0OYCe2i01eoZv5v2t98a1AhForAjQ43R4=; b=evgnAnPfZGfaTIf7eprPWwJa5gO7p6B/KrP4vGiMI4lDyhFLy5xiMw0duQRbifaksR PIpHkFExuWCx/G88QEV0/JXUzO88TEmpkO+7sVYnsDW+BkyQoscCbF8GeA0Ai+wxnvFp yWI7yNd4MAsxPdESmc0e6UgLKF95aVc4YkX+A= MIME-Version: 1.0 In-Reply-To: <4EB2D56C.6070208@gmail.com> References: <4EB14D9D.8080309@gmail.com> <11169846.60.1320306575820.JavaMail.geo-discussion-forums@yqiu15> <4EB2D56C.6070208@gmail.com> Date: Thu, 3 Nov 2011 20:14:31 -0400 Subject: Re: leftover pyc files From: David Robinow To: Andrea Crotti Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1320365673 news.xs4all.nl 6939 [2001:888:2000:d::a6]:60590 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:15315 On Thu, Nov 3, 2011 at 1:54 PM, Andrea Crotti wrote: > All these ideas (shell and git hooks) are nice, but unfortunately > - it's svn not git > - it's windows not *nix > - we have to remove only the ones without the corresponding *py... > -- > http://mail.python.org/mailman/listinfo/python-list > Barely tested. Change the print functions to removes. Pass the top directory as the argument. import os, sys for dirpath, dirnames, filenames in os.walk(sys.argv[1]): if dirpath.endswith("__pycache__"): thispath = dirpath[:-11] for f in filenames: if f.endswith(".pyc"): if not os.path.exists(os.path.join(thispath,f[:-1])): print("delete " + os.path.join(thispath,f)) else: for f in filenames: if f.endswith(".pyc"): if not os.path.exists(os.path.join(dirpath,f[:-1])): print("delete " + os.path.join(dirpath,f)) #os.remove(os.path.join(dirpath,f))