[Python-ideas] question - 'bag' type
C. Titus Brown
ctb at msu.edu
Thu Apr 15 07:12:38 CEST 2010
On Thu, Apr 15, 2010 at 12:08:26AM -0500, Daniel Stutzbach wrote:
> On Thu, Apr 15, 2010 at 12:02 AM, C. Titus Brown <ctb at msu.edu> wrote:
>
> > this seems like the right forum to ask -- is there a reason why Python
> > doesn't have a 'bag' builtin type, e.g.
> >
> Python 2.7 and 3.1 have a Counter type, that is similar to (but not
> identical to) that recipe:
>
> http://docs.python.org/py3k/library/collections.html#collections.Counter
Huh, seems like a different use case from mine -- I just would like to be able
to refer to dictionary keys as attributes. So I guess the cookbook recipe
distracted you from my real interest, which is the short notation:
b = bag(foo=bar, bif=baz)
assert b.foo == bar
assert b.bif == baz
Still curious :)
thanks,
--t
--
C. Titus Brown, ctb at msu.edu
More information about the Python-ideas
mailing list