This will give all files and subdirectories, not just subdirectories. You want to capture all the items, then in the for loop below, test os.path.isdir (and that way you can also get rid of just checking if it's a .pyc file).
Here's a reference: http://stackoverflow.com/questions/800197/get-all-of-the-immediate-subdirectories-in-python