obj[1] *and* obj['foo']

Jonathan Hogg jonathan at onegoodidea.com
Wed Aug 7 21:02:42 CEST 2002

On 7/8/2002 18:01, in article
mailman.1028739733.9996.python-list at python.org, "Christopher A. Craig"
<list-python at ccraig.org> wrote:

> Jonathan Hogg <jonathan at onegoodidea.com> writes:
>> The problem with subclassing list is that you end up in the dark world of
>> Python C-type prototols where sequences and mappings are different things.
>> The type subclassing magic fakes up what looks like a standard __getitem__
>> call, except by that point it's too late and you've been forced through the
>> sequence protocol and the argument must be an integer.
> Subclassing list doesn't actually effect what inputs you can take in
> __getitem__

Hah. You're, of course, absolutely right. I'll be honest, I didn't even
bother to check. I took the OPs problem at face value and made up an answer
in my head ;-)

Must remember to check if there really is a problem before suggesting an


More information about the Python-list mailing list