I guess we see things differently. I think it's quite natural to want a set of unique objects where "unique" is defined as an operation on some subset/conflation/etc. of the attributes of the elements. That's all that the regular set class is, except that it always uses the hash() function to calculate uniqueness. In any event, the notions of set and uniqueness I'm using are well established in other languages, so I don't see why it couldn't be made to work in python.
As far as using a dict, that doesn't really solve my problem. It could be part of a solution, I guess, but I would still need functionality extrinsic to the dict. What I want is to make sure that no values in my set have the same name, and dict won't guarantee that for me. A set that calculated uniqueness based on its elements' names, on the other hand, would. Austin On Thu, Oct 15, 2009 at 1:48 PM, Duncan Booth <duncan.bo...@invalid.invalid> wrote: > It doesn't make sense to use just part of an object as the key for a set. A > set is just a collection of values and there is no key separate from the > value itself. If you build a set from x.name then that works fine, but only > the names are stored. > > What you want in this particular case is a dict: a dict stores both a key > and a value and lets you retrieve the value from the key. > > > -- > Duncan Booth http://kupuguy.blogspot.com > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list