proposed proposal: set.values()

Ron Adam rrr at ronadam.com
Fri Mar 31 14:34:41 EST 2006


Paul Rubin wrote:
> "Terry Reedy" <tjreedy at udel.edu> writes:
>> 1. It is pure duplication that *adds* keystrokes.
>>
> 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.

You could just do the following...


 >>> class vset(set):
...   values = set.copy
...

 >>> s = vset([1,2,3])

 >>> s.values()
vset([1, 2, 3])

 >>> for x in s.values():
...   x
...
1
2
3


Cheers,
   Ron



More information about the Python-list mailing list