using dict vs class __dict__ method to format strings
<p>I have been using dict to format strings</p>

<pre><code>s = '%(name1)s %(name2)s'
d = {}
d['name1'] = 'asdf'
d['name2'] = 'whatever'
result = s % d
</code></pre>

<p>I just realized that I can do this with a class and using the <strong>dict</strong> method
instead:</p>

<pre><code>s = '%(name1)s %(name2)s'
class D : pass
d = D()
d.name1 = 'asdf'
d.name2 = 'whatever'
result = s % d.__dict__
</code></pre>

<p>(obviously I do this for bigger strings, and many keys).</p>

<p>Is there any disadvantage to the class approach that I am overlooking?
Or is there a better method of doing this string formatting that I am missing?</p>

<p>Thank you.</p>
