The os module has functions (os.rmdir, os.removedirs) that can remove empty directories but they will not mess with non-empty ones.

The shutil module has a function (rmtree) that will do this (From this thread in the python mailing list).