Skip to content

Instantly share code, notes, and snippets.

@zommiommy
Last active January 6, 2019 10:35
Show Gist options
  • Save zommiommy/926beb39b3a8a8515e1fb028509ea240 to your computer and use it in GitHub Desktop.
Save zommiommy/926beb39b3a8a8515e1fb028509ea240 to your computer and use it in GitHub Desktop.
GetFileInFolder

A little recursive function that return the list of absolute path of all the file in a folder.

from os import listdir
from os.path import isfile

def get_file_in_folder(path="."):
    if isfile(path):
        return path
    return [get_file_in_folder(path + "/" + subfile) for subfile in listdir(path)]

def flatten(list_of_list):
    return [x for l in list_of_list if type(l) == list for x in l ] + [s for s in list_of_list if type(s) == str ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment