Re: [Python-Dev] dict containment annoyance

2006-08-13 Thread Guido van Rossum
On 8/13/06, Scott Dial <[EMAIL PROTECTED]> wrote: > FWIW, I think the logic of swallowing the TypeError is completely > reasonable. Then you haven't debugged enough Python programs. Swallowing an exception of *any* kind is always a trap waiting to shut when you least expect it, because you have n

Re: [Python-Dev] dict containment annoyance

2006-08-13 Thread Scott Dial
Jean-Paul Calderone wrote: > def blacklisted(o): > try: > # Is the object contained in the blacklist set? > return o in _blacklistset > except TypeError: > # If it *cannot* be contained in the blacklist set, > # then it probably isn't. > return False

Re: [Python-Dev] dict containment annoyance

2006-08-12 Thread Georg Brandl
tomer filiba wrote: > [Aahz] >> -1 >> >> This is seriously no different from an attempt to do >> >> >>> a = {} >> >>> a[ [] ] = 1 > > how so? i'm not trying to modify/store anything in a dict. > i'm only testing if a certain object is contained in the dict. > that's totally different. > imagine th

Re: [Python-Dev] dict containment annoyance

2006-08-12 Thread Jean-Paul Calderone
On Sat, 12 Aug 2006 18:57:02 +0200, tomer filiba <[EMAIL PROTECTED]> wrote: > >the logic is simple: every `x` is either contained in `y` or not. >if `x` *cannot* be contained in `y`, then the answer is a "strong no", >but that's still a "no". > def blacklisted(o): try: # Is the object

Re: [Python-Dev] dict containment annoyance

2006-08-12 Thread David Hopwood
tomer filiba wrote: a={1:2, 3:4} [] in a > > Traceback (most recent call last): > File "", line 1, in ? > TypeError: list objects are unhashable > > imo, the expression should just evaluate to False instead of raising an > exception. it's a question of semantics -- i asked whether the

Re: [Python-Dev] dict containment annoyance

2006-08-12 Thread Aahz
On Sat, Aug 12, 2006, tomer filiba wrote: > > >>>a={1:2, 3:4} > >>>[] in a > Traceback (most recent call last): > File "", line 1, in ? > TypeError: list objects are unhashable > >>> > > imo, the expression should just evaluate to False instead of raising an > exception. -1 This is seriously no