Simplifying code: classes as simple containers in Python
<p>I am trying to write a function <code>drag</code> which can be called as <code>drag('Object1').to('Object2')</code>. The code below works as I want, but it seems using a <code>class</code> simply as a container may be unnecessary:</p>

<pre><code>def drag(source):
    class Container:
        def to(self, target):
            print 'Dragging ' + source + ' to ' + target

    return Container()
</code></pre>

<p>Can the above code be simplified?</p>
