Is it possible to create anonymous objects in Python?
<p>I'm debugging some Python that takes, as input, a list of objects, each with some attributes.</p>

<p>I'd like to hard-code some test values -- let's say, a list of four objects whose "foo" attribute is set to some number.</p>

<p>Is there a more concise way than this?</p>

<pre><code>x1.foo = 1
x2.foo = 2
x3.foo = 3
x4.foo = 4
myfunc([x1, x2, x3, x4])
</code></pre>

<p>Ideally, I'd just like to be able to say something like:</p>

<pre><code>myfunc([&lt;foo=1&gt;, &lt;foo=2&gt;, &lt;foo=3&gt;, &lt;foo=4&gt;])
</code></pre>

<p>(Obviously, that is made-up syntax. But is there something similar that really works?)</p>

<p>Note: This will never be checked in. It's just some throwaway debug code. So don't worry about readability or maintainability.</p>
