En Thu, 12 Apr 2007 01:23:08 -0300, Steven D'Aprano
<[EMAIL PROTECTED]> escribió:
> On Thu, 12 Apr 2007 00:32:32 -0300, Gabriel Genellina wrote:
>
>> First I want to say that __getitem__ should raise IndexError, not
>> KeyError, to indicate "not found"
>
> How do you know the Original Poster's c
Steven D'Aprano wrote:
> On Wed, 11 Apr 2007 16:37:35 -0700, rconradharris wrote:
> ...
> Here are the results under Python 2.5:
>
tester(10)
> Checking index 0...
> Checking index 0...
> Checking index 0...
> Checking index 0...
> Checking index 0...
> [False, 'KeyError', False, 'KeyError',
On Thu, 12 Apr 2007 00:32:32 -0300, Gabriel Genellina wrote:
> First I want to say that __getitem__ should raise IndexError, not
> KeyError, to indicate "not found"
How do you know the Original Poster's class was meant to be a sequence
rather than a mapping?
--
Steven.
--
http://mail.python
On Wed, 11 Apr 2007 16:37:35 -0700, rconradharris wrote:
> A co-worker of mine came across some interesting behavior in the
> Python interpreter today and I'm hoping someone more knowledgeable in
> Python internals can explain this to me.
>
> First, we create an instance of an Old-Style class wit
En Wed, 11 Apr 2007 20:37:35 -0300, <[EMAIL PROTECTED]> escribió:
> First, we create an instance of an Old-Style class without defining a
> __contains__ but instead define a __getitem__ method in which we raise
> KeyError. Next we repeatedly use the 'in' operator to test to see
> whether something
A co-worker of mine came across some interesting behavior in the
Python interpreter today and I'm hoping someone more knowledgeable in
Python internals can explain this to me.
First, we create an instance of an Old-Style class without defining a
__contains__ but instead define a __getitem__ method