[Python-Dev] unscriptable?

Nick Coghlan ncoghlan at gmail.com
Sat Apr 19 14:13:19 CEST 2008


Benjamin Peterson wrote:
> On Fri, Apr 18, 2008 at 5:43 PM, Benjamin Peterson
> <musiccomposition at gmail.com> wrote:
>> Consider this error:
>>  >>> 3["something"]
>>  Traceback (most recent call last):
>>   File "<stdin>", line 1, in <module>
>>  TypeError: 'int' object is unsubscriptable
>>
>>  "unscriptable" seems rather ambiguous. How about "[object] cannot be indexed"?
> Titus just noticed that I confused "unscriptable" with
> "unsubscriptable."  :P Still, though, unsubscriptable seems to be a
> Python invented word.
> What does (un)subscriptable even mean?

You can't pass the object a subscript (the expression between the square 
brackets) and get a meaningful answer.

Being indexable is subtly different from being subscriptable - the 
former has stronger connotations of numeric indices and sequence-like 
behaviour (particularly since the introduction of operator.index), while 
the latter merely states that the container provides some kinds of 
mapping from subscripts to values in the container, without provide any 
implications as to the nature of that mapping.

'Unsubscriptable' may be a bit clumsy, but it's as accurate a 
description of the error as you're likely to find.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org


More information about the Python-Dev mailing list