On 6/3/06, Collin Winter <[EMAIL PROTECTED]> wrote: > My question is this: maybe set/frozenset.__contains__ (as well as > dict.__contains__, etc) should catch such TypeErrors and convert them > to a return value of False? It makes sense that "{} in frozenset([(1, > 2, 3])" should be False, since unhashable objects (like {}) clearly > can't be part of the set/dict/whatever.
Sounds like a bad idea. You already pointed out that it's tricky to catch exceptions and turn them into values without the risk of masking bugs that would cause those same exceptions. In addition, IMO it's a good idea to point out that "{} in {}" is a type error by raising an exception. It's just like "1 in 'abc'" -- the 'in' operation has an implementation that doesn't support all types, and if you try a type that's not supported, you expect a type error. I expect that this is more likely to help catch bugs than it is an obstacle. (I do understand your use case -- I just don't believe it's as important as the bug-catching property you'd be throwing away by supporting that use case.) -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com