Similar to my other post I have created a new little utility and wanted to get some feedback if there is a way to make my script more Pythonic per say. It is a simple tool for Windows that removes empty directory from the Program Files directory because sometimes programs leave behind an empty directory when they uninstall.
import os
def path_exist(path):
return os.path.exists(path)
def list_dir(path):
return os.listdir(path)
def is_dir(path):
return os.path.isdir(path)
def main():
x86_64 = 'C:\\Program Files\\'
x86 = 'C:\\Program Files (x86)\\'
if path_exist(x86_64):
for i in list_dir(x86_64):
i = x86_64 + i
if is_dir(i):
if not list_dir(i):
os.rmdir(i)
print 'Removed', i
if path_exist(x86):
for i in list_dir(x86):
i = x86 + i
if is_dir(i):
if not list_dir(i):
os.rmdir(i)
print 'Removed', i
if __name__ == '__main__':
main()