I have a class with a method called delete that should completely erase the "hold_files" variable. I'd like to mimic deleting an actual folder in the terminal, then itself. For example, "rm -f". Is that possible?
Also, how would I prove that hold_files is completely gone?
class directory:
hold_files = [
'test1.txt', 'test2.py',
{'/desktop': ['computer.txt','tfile.doc',
{'/steph':{
'/pictures': [
'hello.gif',
'smile.gif',
'run.gif'
]},
'/work':[
'file1.txt',
'file2.txt'
]
}]
}
]
#recursively delete folder
def delete(itself):
#if dictionary, call self, else delete
if len(itself)>0:
for f in itself:
print(type(f))
if type(f) is dict:
delete(f)
else:
itself.remove(f)
This is calling the method:
directory.delete(hold_files)
Thank you.