Re: proposed proposal: set.values()
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: proposed proposal: set.values()

From: Ron Adam <rrr@ronadam.com>
Date: Fri Mar 31 2006 - 21:34:41 CEST

Paul Rubin wrote:
> "Terry Reedy" <tjreedy@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
Received on Sun Apr 30 21:48:53 2006