mailbox login(bytes(self username'utf ')bytes(self password'utf ')mailbox select(xdata mailbox search(none'all'messages [for num in data[ split()xmessage mailbox fetch(num'(rfc )'messages append(message[ ][ ]return messages nowif we add all this togetherwe have simple facade class that can send and receive messages in fairly straightforward mannermuch simpler than if we had to interact with these complex libraries directly although it is rarely named in the python communitythe facade pattern is an integral part of the python ecosystem because python emphasizes language readabilityboth the language and its libraries tend to provide easy-to-comprehend interfaces to complicated tasks for examplefor loopslist comprehensionsand generators are all facades into more complicated iterator protocol the defaultdict implementation is facade that abstracts away annoying corner cases when key doesn' exist in dictionary the third-party requests library is powerful facade over less readable libraries for http requests the flyweight pattern the flyweight pattern is memory optimization pattern novice python programmers tend to ignore memory optimizationassuming the built-in garbage collector will take care of them this is often perfectly acceptablebut when developing larger applications with many related objectspaying attention to memory concerns can have huge payoff the flyweight pattern basically ensures that objects that share state can use the same memory for that shared state it is often implemented only after program has demonstrated memory problems it may make sense to design an optimal configuration from the beginning in some situationsbut bear in mind that premature optimization is the most effective way to create program that is too complicated to maintain