Python-patterns – A collection of design patterns/idioms in Python
I wish there was a pattern to encapsulate data and functions from a module.<p>So you could do:<p><pre><code>    import greeter

    greet1 = encapsulate(greeter)
    greet2 = encapsulate(greeter)

    greet1.name = 'Joe'
    greet2.name = 'Sue'

    greet1.greet()
    greet2.greet()
</code></pre>
And greeter.py would look like this:<p><pre><code>    name = 'nobody'
    
    def greet():
        print ('Hello '+name)
</code></pre>
Output:<p><pre><code>    Hello Joe
    Hello Sue
</code></pre>
This would be so much nicer and leaner than classes.