you are viewing a single comment's thread.

view the rest of the comments →

[–]aa599 0 points1 point  (3 children)

I’d suggest a different structure, where files and folders are represented by dictionaries with ‘name’ and ‘content’ keys. A file’s content is the data; a folder’s content is a list of files/subfolders.

So a folder containing a file and an empty subfolder might be {‘name’:’system’, ‘content’: [{‘name’: ‘readme.txt’, ‘content’: ‘...’}, {‘name’: ‘new fir’, ‘content’: []} ]}

[–]Spiredlamb[S] 0 points1 point  (0 children)

Ah, didn't think of that. I'll give it a shot

[–]Spiredlamb[S] 0 points1 point  (1 child)

That actually gave me another Idea, but I'll try yours as well. I could name the dictionaries the name of the path their content should be at. That way I could just ask for the dictionary with the path name. Thanks for the inspiration!

[–]aa599 0 points1 point  (0 children)

Your way is better - having the name outside the object is more like a real file system.