<br><br><div class="gmail_quote">On 15 April 2010 08:02, alex23 <span dir="ltr"><<a href="mailto:wuwei23@gmail.com">wuwei23@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">On Apr 15, 3:02 pm, "C. Titus Brown" <<a href="mailto:c...@msu.edu">c...@msu.edu</a>> wrote:<br>
>    b = bag(foo=bar, baz=bif)<br>
><br>
>    assert b.foo == bar<br>
>    assert <a href="http://b.bz" target="_blank">b.bz</a> == bif<br>
<br>
</div>I've always known this as a 'bunch' after Alex Martelli's recipe[1].<br>
It's handy, but at 3 lines of code not an urgent candidate (IMO) for<br>
stdlib:<br>
<br>
  class Bunch:<br>
    def __init__(self, **kwds):<br>
      self.__dict__.update(kwds)<br></blockquote><div><br><br>Yeah, we've used this class a tonne - especially for testing where you just need a quick object with a bunch of attributes. I think we added a repr as well. It would certainly be a nice harmless addition to the collections module.<br>
<br>Michael<br><br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
[1]: <a href="http://code.activestate.com/recipes/52308-the-simple-but-handy-collector-of-a-bunch-of-named" target="_blank">http://code.activestate.com/recipes/52308-the-simple-but-handy-collector-of-a-bunch-of-named</a><br>

<div><div></div><div class="h5">_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-ideas" target="_blank">http://mail.python.org/mailman/listinfo/python-ideas</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><a href="http://www.ironpythoninaction.com/">http://www.ironpythoninaction.com/</a><br><br><br>