.pyc files...

Christos TZOTZIOY Georgiou tzot at sil-tec.gr
Thu Nov 18 04:44:44 EST 2004


On 17 Nov 2004 22:25:05 GMT, rumours say that Jorgen Grahn
<jgrahn-nntq at algonet.se> might have written:

>> As has already been stated on the list, $() is POSIX.
>
>Sorry, missed that.

>> So sh has it. [...]
>
>Solaris 8's /bin/sh doesn't.

Then Solaris 8 /bin/sh is not POSIX conformant.  However, you could try
if /bin/ksh has it.

>> If you're scripting in csh or tcsh, you're making a
>> fundamental mistake.
>
>I don't.  I'm not even talking about writing scripts, just about deleting
>.pyc files from your average Unix shell (although I hope not many people use
>/bin/sh as their interactive shell, POSIX or not).

Any particular reason for prefering t?csh over POSIX sh other than
habit?  I'm asking out of plain curiosity.

Anyway, nobody in this thread has offered the pythonic solution, so I'll
pretend I am on-topic :)

def remove_pyc_files(root_folder):
    for dirname, dirnames, filenames in os.walk(root_folder):
        for filename in filenames:
            if not filename.endswith('.pyc'): continue
            pathname = os.path.join(dirname, filename)
            os.remove(pathname)

-- 
TZOTZIOY, I speak England very best,
"Tssss!" --Brad Pitt as Achilles in unprecedented Ancient Greek



More information about the Python-list mailing list