The example you give is a dict aside from syntax. What makes it bag-like? Do you expect that I can write<div><br></div><div>b = bag(foo=bar, foo=car)</div><div><br></div><div>But I'd hardly expect b.foo == bar or b.foo == car as you suggest.</div>
<div><br></div><div>--- Bruce</div><div><a href="http://www.vroospeak.com">http://www.vroospeak.com</a><br>
<br><br><div class="gmail_quote">On Wed, Apr 14, 2010 at 10:12 PM, C. Titus Brown <span dir="ltr"><<a href="mailto:ctb@msu.edu">ctb@msu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Thu, Apr 15, 2010 at 12:08:26AM -0500, Daniel Stutzbach wrote:<br>
> On Thu, Apr 15, 2010 at 12:02 AM, C. Titus Brown <<a href="mailto:ctb@msu.edu">ctb@msu.edu</a>> wrote:<br>
><br>
> > this seems like the right forum to ask -- is there a reason why Python<br>
> > doesn't have a 'bag' builtin type, e.g.<br>
> ><br>
> Python 2.7 and 3.1 have a Counter type, that is similar to (but not<br>
> identical to) that recipe:<br>
><br>
> <a href="http://docs.python.org/py3k/library/collections.html#collections.Counter" target="_blank">http://docs.python.org/py3k/library/collections.html#collections.Counter</a><br>
<br>
</div>Huh, seems like a different use case from mine -- I just would like to be able<br>
to refer to dictionary keys as attributes. So I guess the cookbook recipe<br>
distracted you from my real interest, which is the short notation:<br>
<br>
b = bag(foo=bar, bif=baz)<br>
<br>
assert b.foo == bar<br>
assert b.bif == baz<br>
<br>
Still curious :)<br>
<br>
thanks,<br>
--t<br>
<font color="#888888">--<br>
</font><div class="im">C. Titus Brown, <a href="mailto:ctb@msu.edu">ctb@msu.edu</a><br>
</div><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></div>