Christoph Zwerschke <[EMAIL PROTECTED]> writes:
> Ok, the answer is easy: For historical reasons - built-in sets exist
> only since Python 2.4.
>
> Anyway, I was thinking about whether it would be possible and
> desirable to change the old behavior in future Python versions and let
> dict.keys() and dict.values() both return sets instead of lists.

Two (rhetorical, since you dropped the idea) questions:

Are you sure dict.values() should be a set? After all, values aren't
guaranteed to be unique, so dict(a = 1, b = 1).values() currently
returns [1, 1], but would return set([1]) under your proposal.

What about dict.items()?

> For instance, by allowing the set operator "in" for dictionaries,
> instead of "has_key".

"in" already works for dicdtionaries:

>>> d = dict(a = 1, b = 1)
>>> 'a' in d
True
>>> 'f' in d
False
>>> 

> But could other set methods also be useful?

Looks like it.

      <mike
-- 
Mike Meyer <[EMAIL PROTECTED]>                  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to