proposed proposal: set.values()

Paul Rubin http
Fri Mar 31 10:02:45 CEST 2006

"Fredrik Lundh" <fredrik at> writes:
> > Nobody says you shouldn't use list(s) if you know you're dealing with
> > a set.  The idea of s.values() is so you can duck-type between dicts
> > and sets.
> if y is a dict, "x in y" looks for a matching key, not for a
> matching value.

Good point, the duck typing mismatches on "x in y" and there's nothing
that can be done about that.  

Imagine a Bag (multiset) object; it can have multiple occurrences of a
single value.  A keys() operation on it should return unique items,
but values() should return the multiple occurrences.

More information about the Python-list mailing list