[Python-Dev] unscriptable?

Nick Coghlan ncoghlan at gmail.com
Sun Apr 20 03:03:21 CEST 2008

Stephen J. Turnbull wrote:
> Steven writes:
>  > On Sat, 19 Apr 2008 22:13:19 +1000
>  > Nick Coghlan <ncoghlan at gmail.com> wrote:
>  > 
>  > > Being indexable is subtly different from being subscriptable - the 
>  > > former has stronger connotations of numeric indices and sequence-like 
>  > > behaviour 
>  > With my maths background, I would expect that subscripts are (almost)
>  > always numeric, e.g. x-subscript-i means the i-th x value, where i 
>  > is a natural number.
> I don't think you can get general agreement on which tend to connote
> numerical indicies more.

Indices and arrays go hand-in-hand for me (probably due to my signal 
processing background) and I believe PEP 357's choice of __index__ for 
sequence indexing made that association reasonably official in Python terms.

>  On the other hand, in many contexts "index"
> is a general concept,  while "subscript" is a typographical convention
> for representing an index.

Granted, but the latter is explicitly used as the general term for 
sequence indexing and mapping in the relevant section of the language 
reference [1]. So specifically in the context of Python, the error 
message from 'int' is absolutely correct, and the error message from 
'set' isn't technically wrong either (although perhaps not quite as 
correct as it could be).

To suggest yet another colour for the bikeshed, maybe we should ditch 
both unindexable and unsubscriptable and go with "'int' is not a 
sequence or mapping". Any object which supports subscript notation will 
be one or the other.


[1] http://docs.python.org/dev/reference/expressions.html#id7

Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-Dev mailing list