import os.path path = os.getenv('HOME') + '/python' num_files = len([f for f in os.listdir(path)if os.path.isfile(os.path.join(path, f))])