file move('/folder 'folder children {'file ''folder '<__main__ folder object at xb >yeswe can create foldersadd folders to other foldersadd files to foldersand move them aroundwhat more could we ask for in file hierarchywellwe could ask for copying to be implementedbut to conserve treeslet' leave that as an exercise the composite pattern is extremely useful for variety of tree-like structuresincluding gui widget hierarchiesfile hierarchiestree setsgraphsand html dom it can be useful pattern in python when implemented according to the traditional implementationas the example earlier demonstrated sometimesif only shallow tree is being createdwe can get away with list of lists or dictionary of dictionariesand do not need to implement custom componentleafand composite classes other timeswe can get away with implementing only one composite classand treating leaf and composite objects as single class alternativelypython' duck typing can make it easy to add other objects to composite hierarchyas long as they have the correct interface exercises before diving into exercises for each design patterntake moment to implement the copy method for the file and folder objects in the previous section the file method should be quite trivialjust create new node with the same name and contentsand add it to the new parent folder the copy method on folder is quite bit more complicatedas you first have to duplicate the folderand then recursively copy each of its children to the new location you can call the copy(method on the children indiscriminatelyregardless of whether each is file or folder object this will drive home just how powerful the composite pattern can be nowas with the previous look at the patterns we've discussedand consider ideal places where you might implement them you may want to apply the adapter pattern to existing codeas it is usually applicable when interfacing with existing librariesrather than new code how can you use an adapter to force two interfaces to interact with each other correctlycan you think of system complex enough to justify using the facade patternconsider how facades are used in real-life situationssuch as the driver-facing interface of caror the control panel in factory it is similar in softwareexcept the users of the facade interface are other programmersrather than people trained to use them are there complex systems in your latest project that could benefit from the facade pattern