self name name class folder(file)def __init__(selfname)super(__init__(nameself children [root folder(''etc folder('etc'root children append(etcetc children append(file('passwd')etc children append(file('groups')httpd folder('httpd'etc children append(httpdhttpd children append(file('http conf')var folder('var'root children append(varlog folder('log'var children append(loglog children append(file('messages')log children append(file('kernel')this setup code looks like lot of workbut in real filesystemit would be even more involved we' have to read data from the hard drive and structure it into the tree once in memoryhoweverthe code that outputs every file in the filesystem is quite elegantdef walk(file)if isinstance(filefolder)yield file name '/for in file childrenyield from walk(felseyield file name if this code encounters directoryit recursively asks walk(to generate list of all files subordinate to each of its childrenand then yields all that data plus its own filename in the simple case that it has encountered normal fileit just yields that name