What does it mean if a Python object is “subscriptable” or not?

后端 未结 6 2049
情深已故
情深已故 2020-11-22 06:05

Which types of objects fall into the domain of \"subscriptable\"?

6条回答
  •  广开言路
    2020-11-22 06:25

    A scriptable object is an object that records the operations done to it and it can store them as a "script" which can be replayed.

    For example, see: Application Scripting Framework

    Now, if Alistair didn't know what he asked and really meant "subscriptable" objects (as edited by others), then (as mipadi also answered) this is the correct one:

    A subscriptable object is any object that implements the __getitem__ special method (think lists, dictionaries).

提交回复
热议问题